Add font locking to the shorthand prefix of a given printed symbol
name by checking if any of the shorthand prefixes in
read-symbol-shorthands are a prefix for that print name. Although
this does more string comparisons, it didn't prove to be any slower
than the existing approach, and is more correct.
This version is more accurate when highlighting files with many
overlapping shorthands. Given:
;; Local Variables:
;; read-symbol-shorthands: (("bc-" . "breadcrumb-")
;; ("aw-" . "ace-window-")
;; ("zorglub/" . "ace-window-")
;; ("he//" . "hyperdrive-entry--")
;; ("h//" . "hyperdrive--")
;; ("he/" . "hyperdrive-entry-")
;; ("h/" . "hyperdrive-"))
;; End:
The following are correct highlights on print names
'(zorglub/blerh ; hilits "zorglub/" reads to 'ace-window-blerh'
he/foo ; hilits "he/" reads to 'hyperdrive-entry-foo'
he//bar ; hilits "he//" reads to 'hyperdrive-entry--bar'
h/coiso ; hilits "h/" reads to 'hyperdrive-coiso'
h//thingy ; hilits "h//" reads to 'hyperdrive--thingy'
bc-yo ; hilits "bc-" reads to 'breadcrumb-yo'
aw-thingy ; hilits "aw-" reads to 'ace-window-thingy'
)
Co-authored-by: Jonas Bernoulli <jonas@bernoul.li>
Co-authored-by: Joseph Turner <joseph@ushin.org>
* lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands):
* lisp/emacs-lisp/shorthands.el
(shorthands--mismatch-from-end): Rework and document. Works like
CL's mismatch now.
(shorthands-font-lock-shorthands): Allow arbitrary punctuation
as separator for font-locking logic.
* lisp/emacs-lisp/shorthands.el: Declare library as part of the
'emacs' package.
* lisp/epa-ks.el: Declare library as part of the 'epa'
package. (Bug#55388)
This is shorter, simplifies use inside rx expressions, and removes
need for eval-when-compile elsewhere (for later exploitation).
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-symbol): New rx-define.
(lisp-mode-symbol-regexp): Redefine using lisp-mode-symbol.
(lisp-imenu-generic-expression, lisp--el-match-keyword)
(lisp-fdefs, lisp-string-in-doc-position-p):
* lisp/emacs-lisp/checkdoc.el (checkdoc--error-bad-format-p):
* lisp/emacs-lisp/shorthands.el (shorthands-font-lock-shorthands):
Use lisp-mode-symbol instead of lisp-mode-symbol-regexp.