Modernisation of elisp code and conformance with coding guidelines#1247
Modernisation of elisp code and conformance with coding guidelines#1247let-def merged 24 commits intoocaml:masterfrom
Conversation
|
Also: ultimately it should be possible to have a CI action for the elisp code, at least to make sure it byte-compiles cleanly and conforms to package conventions (ie. |
Company will always be loaded when this code is evaluated
This code will execute immediately anyway
auto-complete is likely used in other buffers too, so hard-coding this binding across all of them is inappropriate. Instead, we set it up locally in each buffer. This is still not entirely appropriate, so we only do it as part of the "easy" setup.
2bdf3fb to
deed331
Compare
|
Rebased against conflicting changes in |
|
Note that if there are changes in merlin-eldoc that would help with the elisp that lives in this repository, especially to reduce the maintenance cost, I am happy to accept them |
|
Eventually, I will add these missing sharp quotes: |
Sure, I can do that as part of this PR. |
748c578 to
1469d12
Compare
|
The build failures seem spurious here, by the way. |
|
This looks cool. Is it going to be merged? |
Yes, I probably will start doing so before long. :-) |
Can you wait a bit? Some users built custom extensions using merlin elisp functions, we need to make sure this is not going to break anything. |
Sure, I thought @Khady already expressed that he was happy with the changes. Let's hear from him again though. |
|
We were thinking about people from janestreet actually. We've notified them offline. |
emacs/merlin-iedit.el
Outdated
| "-identifier-at" (merlin-unmake-point (point))))) | ||
| (when r | ||
| (if (listp r) | ||
| (flet ((iedit-printable (a) |
There was a problem hiding this comment.
How about replacing the flet here with a cl-letf that would remove a usage of a deprecated function?
| (flet ((iedit-printable (a) | |
| (cl-letf ((iedit-printable (a) |
There was a problem hiding this comment.
Thanks, that's not quite the right formulation because it's not a drop-in equivalent, but I've made a subsequent change in this spirit. 👍
The var will always be bound at this point, because the iedit feature has been required.
|
Thanks for your work :) |
|
Thanks @let-def -- if anyone reports issues subsequently, please CC me and I will help. The packages on MELPA will be split according to the optional third-party package dependencies now: |
…idelines (ocaml#1247) * [emacs] Remove unnecessary eval-after-load Company will always be loaded when this code is evaluated * Require cl-lib instead of deprecated cl * Assume Emacs 24.3 and enable lexical-binding * Eliminate dynamically-scoped var * Fix warnings about unused lexical variables * Remove redundant eval-after-load This code will execute immediately anyway * Inline merlin-setup * Assume Emacs 25.1 (2016 release) and enable xref backend unconditionally * Don't modify the global ac-complete-mode-map auto-complete is likely used in other buffers too, so hard-coding this binding across all of them is inappropriate. Instead, we set it up locally in each buffer. This is still not entirely appropriate, so we only do it as part of the "easy" setup. * Make merlin-ac a separate package with correct dependencies * Make merlin-company a separate package with correct dependencies * Make merlin-iedit a separate package with correct dependencies * Avoid "merlin/" prefix, which breaks elisp naming conventions * Prefer cl-case / pcase to repetitive conds * Fix comment types * merlin-lookup is just "assoc-default" * Define obsolete function aliases to keep merlin-eldoc compatible * Fix prefix of bounds-of-ocaml-atom-at-point * Prefer to sharp-quote functions when adding hooks etc. Thanks @Fourchaux * Ignore .elc files * merlin-iedit: drop references to now-removed var and function in iedit * Prefer cl-letf to deprecated flet * Remove redundant bound-and-true-p test The var will always be bound at this point, because the iedit feature has been required.
…idelines (ocaml#1247) * [emacs] Remove unnecessary eval-after-load Company will always be loaded when this code is evaluated * Require cl-lib instead of deprecated cl * Assume Emacs 24.3 and enable lexical-binding * Eliminate dynamically-scoped var * Fix warnings about unused lexical variables * Remove redundant eval-after-load This code will execute immediately anyway * Inline merlin-setup * Assume Emacs 25.1 (2016 release) and enable xref backend unconditionally * Don't modify the global ac-complete-mode-map auto-complete is likely used in other buffers too, so hard-coding this binding across all of them is inappropriate. Instead, we set it up locally in each buffer. This is still not entirely appropriate, so we only do it as part of the "easy" setup. * Make merlin-ac a separate package with correct dependencies * Make merlin-company a separate package with correct dependencies * Make merlin-iedit a separate package with correct dependencies * Avoid "merlin/" prefix, which breaks elisp naming conventions * Prefer cl-case / pcase to repetitive conds * Fix comment types * merlin-lookup is just "assoc-default" * Define obsolete function aliases to keep merlin-eldoc compatible * Fix prefix of bounds-of-ocaml-atom-at-point * Prefer to sharp-quote functions when adding hooks etc. Thanks @Fourchaux * Ignore .elc files * merlin-iedit: drop references to now-removed var and function in iedit * Prefer cl-letf to deprecated flet * Remove redundant bound-and-true-p test The var will always be bound at this point, because the iedit feature has been required.
…idelines (#1247) * [emacs] Remove unnecessary eval-after-load Company will always be loaded when this code is evaluated * Require cl-lib instead of deprecated cl * Assume Emacs 24.3 and enable lexical-binding * Eliminate dynamically-scoped var * Fix warnings about unused lexical variables * Remove redundant eval-after-load This code will execute immediately anyway * Inline merlin-setup * Assume Emacs 25.1 (2016 release) and enable xref backend unconditionally * Don't modify the global ac-complete-mode-map auto-complete is likely used in other buffers too, so hard-coding this binding across all of them is inappropriate. Instead, we set it up locally in each buffer. This is still not entirely appropriate, so we only do it as part of the "easy" setup. * Make merlin-ac a separate package with correct dependencies * Make merlin-company a separate package with correct dependencies * Make merlin-iedit a separate package with correct dependencies * Avoid "merlin/" prefix, which breaks elisp naming conventions * Prefer cl-case / pcase to repetitive conds * Fix comment types * merlin-lookup is just "assoc-default" * Define obsolete function aliases to keep merlin-eldoc compatible * Fix prefix of bounds-of-ocaml-atom-at-point * Prefer to sharp-quote functions when adding hooks etc. Thanks @Fourchaux * Ignore .elc files * merlin-iedit: drop references to now-removed var and function in iedit * Prefer cl-letf to deprecated flet * Remove redundant bound-and-true-p test The var will always be bound at this point, because the iedit feature has been required.
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct:
+ improve prefixing of generated constructors in Destruct by filtering
opened modules (ocaml/merlin#1277)
+ make the destruct command more resilient to ill-typed expressions and
when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- reintroduce some record recovery and improve completion (ocaml/merlin#1276)
- introduce a new AST node for holes (`_`), allow correct typing of these
holes and add a new `holes` command that returns the locations of all
holes in the current file along with their types (ocaml/merlin#1242, ocaml/merlin#1289)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- Windows: system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- vim: Add `MerlinNextHole` and `MerlinPreviousHole` commands to navigate
between holes. Jump to the first hole after destruct (ocaml/merlin#1287, ocaml/merlin#1303)
- emacs: Add `merlin-next-hole` and `merlin-previous-hole` commands to
navigate holes. Jump to the first hole after calling destruct. (ocaml/merlin#1291)
- emacs: modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover constructor disambiguation and record fields (ocaml/merlin#1276)
- cover the new `holes` command and AST node (ocaml/merlin#1242, ocaml/merlin#1289)
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
CHANGES:
Tue Apr 12 11:44:22 AM CET 2021
+ merlin binary
- external configuration reading:
+ use relative paths to communicate with Dune when possible. This solves
issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
fixes ocaml/merlin#1288)
+ make the `workdir` configuration value when using the
`dune ocaml-merlin` configuration provider the same as when using
`dot-merlin-reader` so that ppxes behaves in the same way as before
(ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
- destruct: make the destruct command more resilient to ill-typed
expressions and when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
- Mppx: don't restore cookies after invocation. Ppx are invoked only once
so there is no need to manage cookies. This small change should increase
performance and should not change any other behavior (ocaml/merlin#1309)
- windows:
+ system command variant: do not open a window console when
launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
+ fix Emacs hanging when starting Merlin (ocaml/merlin#1263)
+ fix path canonicalization (ocaml/merlin#1254)
- fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
+ editor modes
- emacs:
+ modernization of the elisp code and conformance with coding
guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
+ use opam var where applicable (ocaml/merlin#1310)
+ fix "wrong number of argument" (ocaml/merlin#1250 by @atharvashukla, fixes ocaml/merlin#1234)
+ fix for Neovim's CursorMoved semantics (ocaml/merlin#1213 by @ddickstein)
- vim & emacs : new client-side "merlin use package" commands, restoring
previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
+ test suite
- cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
This reverts commit 3c0a72f.
…oding guidelines (ocaml#1247)" This reverts commit 4e382a7.
…lines (ocaml#1247)" This reverts commit 30c52bf.
I set about tidying up the merlin elisp to match GNU and package conventions and best practices. By targeting a post-2015 Emacs, we also improve the out-of-the-box experience by automatically enabling the xref backend. Everything is split up into self-explanatory commits, and I'm happy to make adjustments if desired.
I've tested this locally, including its operation with the
merlin-eldocpackage. (I actually think the core eldoc behaviour should be included inmerlinitself and I might make a follow-up PR to add that.)