Emacs-D-Mode-Maintainers / Emacs-D-Mode

An Emacs mode for D code.
GNU General Public License v3.0
84 stars 21 forks source link

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

Closed TLINDEN closed 8 years ago

TLINDEN commented 9 years ago

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

russel commented 9 years ago

Hummm… the code causing the problem is that for dealing with D-specific static if/else issues. It appears to have been written on the assumption that add-function and the others were added in 24.0 rather than 24.4. I think the code must have been added after I switched to 24.4 as I have never seen the problem. At first sight the correct immediate fix would be to amend the version check to ensure > 24.3. However this would then leave a lot of new, but old, unfixed bugs for people using 24.[0123], until someone wrote the equivalent functionality without add-function etc. I guess this is a judgement call for those using 24.[0123] which is the lesser of two evils.

russel commented 9 years ago

As an experiment, I have added extra version checks in the code I believe is problematic. I only have 24.4 and 24.5 so I cannot check for the problem and its resolution. I have pushed a branch with the fix to my GitHub repository: https://github.com/russel/Emacs-D-Mode/tree/advice-issue. If you check this compared to the official version to see if it makes any difference. Also if you could post a small code file that enables you to see the problem that would be helpful.

TLINDEN commented 9 years ago

I tried it with precisely the same rresults as bevore (same warning during build and same message in emacs at runtime). The code I used is the sample on the frontpage on dlang.org (without shebang and comment). Pasted it into emacs, went to line 5, pressed , went to line 6, pressed again which doesn't work anymore. The error appears when I press the second time (in line 6).

dmakarov commented 9 years ago

I made a PR #51 that at least should enable using d-mode in Emacs versions before 24.4. It's correct at least from the point of view of not using old style defadvice with the new macros add-function/remove-function.

russel commented 9 years ago

I committed this change to master, so it should appear in MELPA soon. I will delete my tinkering branch.

CyberShadow commented 8 years ago

So can this be closed, then?

russel commented 8 years ago

Yes let's close this issue. If the problem resurfaces, a new issue can be started (which is probably better than reopening this one).