Giter Site home page Giter Site logo

emacs-d-mode's Introduction

Emacs D Mode

Licence Build Status Coverage Status MELPA MELPA Stable

An Emacs major mode for editing D code.

This mode is currently known to work with Emacs 25 and 26. For best results, use Emacs 26.

The best way of installing this major mode, at least for Emacs 26, is to use the packaging system. Add MELPA or MELPA Stable to the list of repositories to access this mode. For those who want only formal, tagged releases use MELPA Stable:

(require 'package)
(add-to-list 'package-archives
         '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

For those who want rolling releases as they happen use MELPA:

(require 'package)
(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

and then use M-x package-list-packages to get to the package listing and install from there. MELPA tracks this Git repository and updates relatively soon after each commit or formal release. For more detail on setting up see MELPA Getting Started.

The master of all the material is the Git repository at https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode .

This software is licenced under GNU General Public Licence version 2.

emacs-d-mode's People

Contributors

britishempire avatar cybershadow avatar dmakarov avatar dylangleason avatar finalpatch avatar lmbarros avatar martinnowak avatar nordlow avatar radenling avatar russel avatar sdilts avatar snosov1 avatar ssb22 avatar togos avatar wrzoski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emacs-d-mode's Issues

enums with a base type incorrectly indent

I don't know if this is a ccmode indentation I can change, but here's what goes wrong:

enum GCode_Command : string // set the base type to be string
{
  RLM = "G00", // this one indents correctly 
    FRM = "G01", // this doesn't 
    OFFR = "G42" // ditto for this one
}

in addition, there is no highlighting done for the enum members

Compilation fails

On Emacs 24.3.1 I get the following error when trying to install d-mode from melpa:

Compiling file /home/drorl/.emacs.d/elpa/d-mode-20140813.1033/d-mode.el at Thu Aug 21 13:39:42 2014

In d-mode:
d-mode.el:434:9:Warning: (lambda nil ...) quoted with ' rather than with #'
d-mode.el:434:9:Warning: (lambda nil ...) quoted with ' rather than with #'
d-mode.el:494:1:Error: End of file during parsing

Version should be declared for MELPA Stable

This Emacs mode currently uses a rolling release strategy with versions being the date of last change. The date is embedded in the file (but is invariable wrong), fortunately the MELPA release version number is the Git commit date. This would imply removing the version number from the files would be a good idea, but then how would people know any particular source file version?

There is now (has been for a while) a MELPA Stable. This requires a formal version number tag in a specific format. The implication is some form of semantic versioning. This bit is easy, just use Git tags. However should the stable version number be in the file?

How to distinguish an update with rolling release via MELPA from a stable release with a version tag?

DDOC support?

Is there someone adding support for DDOC? If none, would like to try working on it if there is interest from others. In doing that, I also need some more information:

  1. About DDOC, the best documentation I can get so far is https://dlang.org/spec/ddoc.html. Any better sources?
  2. Should I modify d-mode.el or what is the better way? I am thinking about doing the former, but it may mess up with functionality for normal d files.

Indentation is wrong for an enum with EnumBaseType

For an enum with a base type:

  enum : char {
    eof = cast(char)-1,
      openParen = '(',
      closeParen = ')',
      comment = ';'
  };

The indentation for all lines after the first (in this case eof) are indented one extra level. This does not occur with enums that don't have a base type specified.

dfmt

Hello. Recently I found a module https://github.com/nordlow/elisp/blob/master/mine/dfmt.el by nordlow.

And I modify it (thanks Syohei Yoshida). The result can be found here https://github.com/qsimpleq/elisp-dfmt

Pls try and test it.

When I wanted to add the recipe to melpa, milkypostman say

i think this package would fit better in the d-mode package. Have you tried reaching out to the maintainers? it would be better as an on-save hook i think.
https://github.com/melpa/melpa/pull/4044

So the question is - do the authors wish to include this module in the d-mode?

Problem Compiling on Emacs 24.2

I get the following byte-compiler error

d-mode.el:61:1:Warning: cl package required at runtime
d-mode.el:300:1:Error: Wrong type argument: stringp, #[nil "\300\207" ["/*"] 1 "/*"]

when I try to compile d-mode.el on Emacs 24.4.

Clues anyone?

Create package testing infrastructure.

I created a basic infrastructure to test d-mode package. For now, it only checks whether the package compiles or not. In future I hope to add tests to validate that d-mode can analyze D source files correctly. In my opinion it's already useful to verify automatically that the package compiles on a pull request.

It's now on testing branch of my fork and linked to travis-ci and coveralls continuous integration servers. https://github.com/dmakarov/Emacs-D-Mode/tree/testing

If you consider it valuable and are interested in having it in the main repository, I will merge it to my master branch and submit a pull request. The links in README.md will have to be updated and Emacs-D-Mode-Maintainers accounts on travis-ci.org and coveralls.io have to be connected to Emacs-D-Mode repository. As far as I understand this should not affect how the package is pushed to and distributed by ELPA.

Load Fail on Emacs Snapshot 24.3.50.1

When trying to load either d-mode.el or d-mode.elc on recent snapshot of Emacs load fails as

Eval error in the `c-lang-defconst' for `c-typedef-decl-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-prefix-spec-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-keywords' in d-mode:
Eval error in the `c-lang-defconst' for `c-regular-keywords-regexp' in d-mode:
Eval error in the `c-lang-defconst' for `c-basic-matchers-before' in d-mode:
Eval error in the `c-lang-defconst' for `c-matchers-2' in d-mode:
Eval error in the `c-lang-defconst' for `c-typedef-decl-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-prefix-spec-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-keywords' in d-mode:
Eval error in the `c-lang-defconst' for `c-regular-keywords-regexp' in d-mode:
Eval error in the `c-lang-defconst' for `c-basic-matchers-before' in d-mode:
Eval error in the `c-lang-defconst' for `c-matchers-2' in d-mode:
Eval error in the `c-lang-defconst' for `c-typedef-decl-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-prefix-spec-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-keywords' in d-mode:
Eval error in the `c-lang-defconst' for `c-regular-keywords-regexp' in d-mode:
Eval error in the `c-lang-defconst' for `c-basic-matchers-before' in d-mode:
Eval error in the `c-lang-defconst' for `c-matchers-2' in d-mode:
Eval error in the `c-lang-defconst' for `c-typedef-decl-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-prefix-spec-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-keywords' in d-mode:
Eval error in the `c-lang-defconst' for `c-regular-keywords-regexp' in d-mode:
Eval error in the `c-lang-defconst' for `c-basic-matchers-before' in d-mode:
Eval error in the `c-lang-defconst' for `c-matchers-2' in d-mode:
Eval error in the `c-lang-defconst' for `c-typedef-decl-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-prefix-spec-kwds' in d-mode:
Eval error in the `c-lang-defconst' for `c-keywords' in d-mode:
Eval error in the `c-lang-defconst' for `c-regular-keywords-regexp' in d-mode:
Eval error in the `c-lang-defconst' for `c-basic-matchers-before' in d-mode:
Eval error in the `c-lang-defconst' for `c-matchers-2' in d-mode:
Load error for /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.el:
(error Recursive load /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.elc /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.elc /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.elc /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.elc /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.elc /home/per/.emacs.d/elpa/d-mode-20130807.32/d-mode.el)

Compilation errors from builds using dub (or using the -vcolumns dmd flags) are not recognized in compilation buffer

Hi,

I've been scratching my head for a while as to why the compilation buffer wouldn't highlight compilation error messages when building a project with dub until I realized that dub adds the -vcolumns command line option to dmd.

I fixed this by adding the following new entry to the compilation-error-regexp-alist list.

(add-to-list 'compilation-error-regexp-alist-alist
    '(dmd-vcolumns
        "^\\([^ \n]+\\)(\\([0-9]+\\),\\([0-9]+\\)): \\(?:Error\\|.\\|warnin\\(g\\)\\|remar\\(k\\)\\)"
        1 2 3 (4 . 5)))
(add-to-list 'compilation-error-regexp-alist 'dmd-vcolumns)

Feel free to merge this under the same license as the rest of the code.

Cheers,

JB

if template constraints aren't indented correctly

If you have templates contstrainst on the second line of a template or function template definition, it is indented an extra level. For Example:

void foo(T)(T stuff)
    if (isInputRange!T) {

instead of:

void foo(T)(T stuff)
if (isInputRange!T) {

no indentation for the continued line seems to be the norm in most D code I have seen.

Error "c-add-stmt-syntax: Symbol's function definition is void: add-function"

I type the following into Emacs (GNU Emacs 24.3.1 (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 AppKit 1138.51)) after installing d-mode via package-install:

import std.stdio;
void main() {
  string s = "hi there";
}

Upon completing the final closing-brace, Emacs gives the error (in *Messages*): c-add-stmt-syntax: Symbol's function definition is void: add-function.

Further text entered inside main won't be correctly indented, with the above error being continually given.

Indentation in latest emacs triggers error (with patch)

The latest emacs versions introduce a new type of keyword which d-mode does not provide.
As a result, the looking-at function receives nil and fails, inside a call to c-after-conditional.
In the patch provided I define the keyword variable, with seems to solve the problem.

--- d-mode.el.orig  2014-11-07 16:58:46.786635665 +0100
+++ d-mode.el   2014-11-07 16:55:52.973297053 +0100
@@ -244,6 +244,11 @@
       "foreach" "foreach_reverse" "with" "unittest"
       "else static if" "else"))

+(c-lang-defconst c-block-stmt-1-2-kwds
+  ;; Statement keywords which may be followed by a
+  ;; paren sexp and will then be followed by a substatement.
+  d '())
+
 (c-lang-defconst c-simple-stmt-kwds
   ;; Statement keywords followed by an expression or nothing.
   d '("break" "continue" "goto" "return" "throw"))

Contracts are more indented than body

The following is the indentation I get for contracts:

double foo (double b)
    in
    {
        assert(b == b);
    }
out (result)
    {
        assert(result == result);
    }
body
{
    return b;
}
double foo (double b)
    out (result)
        {
            assert(result == result);
        }
body
{
    return b;
}
double foo (double b)
    in
    {
        assert(b == b);
    }
body
{
    return b;
}

My settings are:

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(defvaralias 'c-basic-offset 'tab-width)
(setq c-default-style "bsd" c-basic-offset 4)

But it happens when commenting those lines out too.

both `minimap-mode` and `sublimity-mode` don't work in `d-mode`

Hello,

As above. Using versions:
sublimity-20170820.827 from ELPA.
d-mode-20180215.727 from ELPA
minimap-1.2 from GNU
GNU Emacs 25.3.1 (x86_64-apple-darwin17.4.0, Carbon Version 158 AppKit 1561.2) of 2018-03-01 from homebrew (package emacs-mac)
OSX 10.13.3

This also happens if I load emacs with -Q, load the minimap and d-mode packages and open any random file in D-mode (vs in another mode, such as built in python-mode). I was only able to verify with minimap, since sublimity does not appear to work in other modes either if I just load it - will make another attempt when time permits.

[ENH/BUG] Support version / else version / else pattern

According to the specs, the following code:

version (SomeVersion)
{
}
else
    version (SomeOtherVersion)
    {
    }
else
{
    static assert (0, "Fail");
}

Should have the last else indented at the same level as version (SomeOtherVersion).

However, one common idiom is the following:

version (SomeVersion)
{
}
else version (SomeOtherVersion)
{
}
else
{
    static assert (0, "Fail");
}

Which basically allow us to use version as if. would it been possible to get both (bug fixed when version is on a newline after an else, and right alignment of braces when we have else version) ?

micro Readme.md correction

and then use M-x package-list-package to get to... -> and then use M-x package-list-packages to get to ...

Compilation warnings

When compiling (GNU Emacs 24.2.1) I get these warnings:

d-mode.el:291:1:Warning: defcustom for `d-font-lock-extra-types' fails to
specify containing group
d-mode.el:422:1:Warning: (lambda nil ...) quoted with ' rather than with #'
d-mode.el:422:1:Warning: (lambda nil ...) quoted with ' rather than with #'

I don't know whether they are important or not, close this if they're harmless.

d-mode not working under emacs25

Hi (and thanks for d-mode! :),

I've just upgraded to emacs 25.1 and d-mode complains (and does not work) with these messages:

Eval error in the ‘c-lang-defconst’ for ‘c-opt-cpp-prefix’ in d-mode:
Eval error in the ‘c-lang-defconst’ for ‘c-cpp-matchers’ in d-mode:
Eval error in the ‘c-lang-defconst’ for ‘c-matchers-1’ in d-mode:
c-get-lang-constant: Invalid function: "\\s *#\\s *"

Is there any chance to get a fix for this error?
Thanks!
A. Corbi

Enum misaligned / missing coloration

Hi,
First, let me thank you for the work ! I use almost exclusively emacs and this is very precious to me.
I ran into a little indent bug with enums. The following:

enum Mode {
None = 0,
Auth = 1,
Stream = 2
}

has 2 extra space in front of Auth and Stream, and the closing bracket should be aligned with the 'e' of enum.
In addition, in c-mode and c++-mode, the enum name are colored like variable name, so I guess they should be colored in D as well.
Thanks in advance !

void-function set-difference error

D Mode uses set-difference from cl without requiring cl, which causes a void-function error if cl is not loaded.

You need a (require 'cl).

Hosting for release tarball

Where is the right place to host release tarballs? I seem to recollect GitHub no longer provides such a service.

As far as I understand it, MELPA will automatically pick up any commits to the mainline and publish it for everyone using Emacs 24+ and the packaging system.

It would be good to get releases packaged by Debian and Fedora.

Incorrect escaping of string litterals

import std.stdio;
void main() { writeln(`This is an embedded \`); }

Emacs-D-Mode will highlight everything after the first backslash as string literal, but it shouldn't.

Release 2.0.6

The current repository version of d-mode looks good at first glance. It has been half a year since the last commit, and I don't see any open issues (expect this one here in a moment). Wouldn't this be a good time to officially tag the current state of affairs as 2.0.6? By the way, this might also help to get (a recent) d-mode into Gentoo. Other distros would likely benefit as well.

Not working properly on Emacs 24.4

I mention the Emacs version because it's the only thing I can think of that's changed in my setup recently. I can't see anything in d-mode's recent git history that could explain the change in behaviour. Right now syntax highlighting doesn't work half of the time and even tab indentation failed for me on the last file I tried editing. I thought maybe the highlighting was a solarized issue but I changed colour scheme and the problem was the same.

Emacs 24.3.1 Symbol's function definition is void: add-function

I've emacs 24.3+1-2ubuntu1 installed on Ubuntu 14.04 LTS and using latest d-mode.el (installed today). I loaded a small sample source and pressed TAB to re-indent. It works for the first line but not for subsequent lines. In messages the following error appears:

progn: Symbol's function definition is void: add-function

Afaik add-function appears first on emacs 24.4. Also I get the following when compiling it:

In end of data:
d-mode.el:662:1:Warning: the following functions are not known to be defined:
    add-function, remove-function, advice-add

Would it be possible to make d-mode backwards compatible since I'm not going to upgrade my system just for d-mode (it's a Dell XP13 developer edition and I'm just glad everything works now).

Thanks,
Tom

Project logo

Currently this project doesn't have a logo.

Here are some simple proposed variants:

Occasional incorrect fontification of string literals due to escapes

Fontification of string literals, for instance, in module std.net.isemail.d at line 907 on (git master) fails for me.

The line contains

    assert("\"test\\\u0000\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
        EmailStatusCode.deprecatedQuotedPair);

Another failure starts at line 1699

        backslash = `\`,
        dot = ".",
        doubleQuote = `"`,
```.

Drop support for Emacs 23

Since it was committed, Dmitri's .travis.yml doesn't seem to work any longer. I had a go at fixing it and wasn't successful, so I looked at what other people are doing. Flycheck has a reusable emacs-travis.mk project, which seems to be the only actively maintained Travis integration project for Emacs CI. However, it doesn't support anything before 24.3 (not as much its fault, as Emacs' install script apparently not supporting non-root installation back then).

As such, I suggest that we stop supporting Emacs 23, and move forward with breaking changes (such as replacing usage of the cl package with non-deprecated replacements). Since the earliest version that emacs-travis.mk supports is Emacs 24.3, I suggest that that become our oldest "officially-supported" version.

Different package highlight for import

Currently those two lines are highlighted differently:

import foo.bar;
import foo.Bar;

The later line has the package in purple, and the module in green, while the former has the package uncoloured.

GNU Emacs 25.1.50.1
d-mode             20151205.2354 installed             D Programming Language major mode for (X)Emacs

Indentation of Multi-Line UFCS-Chains

I would love to see the indentation mechanism in d-mode be tweaked to enable indentation of multi-line UFCS-chains in ways such as

        foreach (file; dirPath.expandTilde()
                              .buildNormalizedPath() 
                              .dirEntries(SpanMode.shallow)()
                              .filter!(name => name.extension == ".csv")) // I love D :)

Does any one know if this is possible without changing the internals of Emacs?

http://www.emacswiki.org/emacs/IndentingC might be of service for ideas. I cannot find the symbol align-mode-rules-list in my Emacs though. Misspelling?

Automatic Indentation does not work

It seems like automatic indentaion (I use newline-and-indent) does not work in d-mode. Is there some specific setup needed to get it to work?

Sluggish and Incorrectly Highlighted Type-Qualified Enums

On latest stable Emacs 24.4.1 d-mode.el's parsing and syntax highlightning doesn't work correctly for type-qualified enums such as

enum BasicEmotions:ubyte
{
    fear, // some comment
    anger, // some other comment
}

eventhough my d-mode.el contains the section

(c-lang-defconst c-colon-type-list-kwds
  ;; Keywords that may be followed (not necessarily directly) by a colon
  ;; and then a comma separated list of type identifiers.
  d  '("class" "enum" "interface"))

The coloring is flashy and makes interaction sluggish for enums with many enumerators.

Highly annoying.

Anybody know a solution?

Do we need to fix d-mode.el or Emacs' builtin cc-mode stuff?

Managing indentation

The following has been excised from the code itself and posted here as an issue. If it is no longer an issue then this can be closed. If it remains an issue then we now have a more appropriate record of it.

I tried making "with" "version" and "extern" be their own
c-other-block-decl-kwds. Which is supposed to mean that you
can control the indentation on the block following them
individually. It didn't seem to work right though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.