evil
evil copied to clipboard
Various code cleanups
The original motivation was to fix the misuse of eval in evil-delay by turning it into a macro (name evil-with-delay). But it includes various generic changes such as prefering #' to quote function names and fixing some incorrect uses of ' in docstrings (many warnings remain about this).
The patch also enables lexical-binding in the remaining files. lexical-binding in evil-ex.el has had a tumultuous life, the last commit of which sets it explicitly to nil while stating confusingly in the commit message that it re-enables it. In any case, I still found some changes needed to account for lexical-binding, so there might be more.
Detailed changes below.
-
evil-common.el (evil-unquote): Delete function, not used (luckily: it reeked of a bad hack to work around a misunderstood bug). (evil--with-delay): New helper function. (evil-with-delay): New macro to replace
evil-delay. (evil-delay): Rewrite usingevil-with-delayand mark as obsolete. (evil-signal-at-bob-or-eob): Fix typos in docstring. -
evil-core.el (window-configurakion-change-hook): Add FIXME. (evil-define-key): Use
evil-with-delay. -
evil-states.el (evil-visual-activate-hook): Use
evil-with-delay. -
evil-commands.el (evil-match): Use
pcasesince the branch patterns used are those ofpcaserather than those ofcl-case. (evil-execute-in-normal-state): Useevil-with-delay. -
evil-digraphs.el (evil-digraphs-table-user): Remove redundant
:grouparg. -
evil-ex.el: Enable
lexical-bindinglike the last commit that touched this cookie said that it was doing (even though it didn't). (evil-ex-info-string): Declare. (evil-ex-update): Markendandlenas ignored. (evil-ex-init-shell-argument-completion): Markargas ignored. (evil-flatten-syntax-tree): Markcharas ignored. (evil-parser): Renamecontexttoevil--contextand declare it as dynbound. Remove unused varlast. Move sharedsetq resultout of someifs andconds. -
evil-jumps.el: Remove redundant :group` arguments.
-
evil-macros.el (evil-define-interactive-code): Move shared
setq funcout ofcond. Move the insertion of quote aroundfuncto thecondso thequoteis not incorrectly added around lambda forms. -
evil-pkg.el: Remove file. Move its contents to the pseudo headers of
evil.elso (M|NonGNU)ELPA can auto-generate this file appropriately. -
evil.el: Enable
lexical-binding. Synchronize metadata with what was inevil-pkg.el. -
evil-tests.el: Enable
lexical-binding. (evil-test-change-state): Moveletto obviate the need forsetq. Remove unused varskeymapandlocal-keymap. (evil-test-auxiliary-maps): Renamemaptoevil--mapand declare it as dynbound soevil-define-keycan access it. (evil-test-exclusive-type): Markthird-lineas unused. (evil-test-text-object): Marktypearg as unused. (evil-with-both-search-modules): Move macro before its first use. (evil-test-properties): Renamealisttoevil--alistand declare it as dynbound soevil-put-propertycan access it. -
evil-command-window.el (evil-command-window-draw-prefix): Mark
ignoredas, well, ignored.
Closes #1685
@monnier I rebased this onto master and pushed a commit that fixed the tests and added some optional suggestions. Would be great to get this merged. Two comments:
- This causes quite a lot of bytecomp warnings in evil-vars.el due to the now sharp-quoted functions.
- How does this compare to pull request #1419?
@monnier I rebased this onto master and pushed a commit that fixed the tests and added some optional suggestions.
Thanks a lot.
- This causes quite a lot of bytecomp warnings in evil-vars.el due to the now sharp-quoted functions.
Yup. Some of them can probably be addressed with a few requires, but
probably not all. Maybe it's best to refrain from using those #'
thingies in the key bindings for now.
- How does this compare to pull request #1419?
It short-circuits the "quote the code in the function and then try to undo the damage in the compiler macro" by using a macro :-)
I pushed to the scratch/evil branch of git://git.sv.git.org/emacs/nongnu.git a reworked version of this patch, split into various commits so it's easier to merge it piecemeal. It also refrains from using #' at those places where it would currently end up adding a "spurious" warnings (fixing those warnings is currently rather inconvenient because of the circular dependencies we have between files).
It also adds one important change which is to replace the use of defadvice with advice-add.
For the readers, the review for this PR per my understanding is happening here https://github.com/emacs-evil/evil/issues/1819
I also stumbled upon this PR because upstream (not yet released) Emacs has deprecated defadvice, so would nice to have this fixed