Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate command key substitution and example block enclosing #1156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aagon
Copy link

@aagon aagon commented Jan 12, 2023

The following form :

(replace-regexp-in-string "\\\\{[^}]+}"
			  (lambda (match)
			    (substitute-command-keys match))
			  "\\{yas-minor-mode-map}")

produces the following error in emacs 28+ :

Debugger entered--Lisp error: (args-out-of-range 21 22)
  replace-regexp-in-string("\\\\{[^}]+}" (closure (t) (match) (substitute-command-keys match)) "\\{yas-minor-mode-map}")
  (progn (replace-regexp-in-string "\\\\{[^}]+}" #'(lambda (match) (substitute-command-keys match)) "\\{yas-minor-mode-map}"))
  elisp--eval-last-sexp(t)
  eval-last-sexp(t)
  eval-print-last-sexp(nil)
  funcall-interactively(eval-print-last-sexp nil)
  command-execute(eval-print-last-sexp)

This is what makes the function yas--document-symbol error out during documentation build (see #1147). This form must have been valid in previous versions of emacs.

This specific block of the function yas--document-symbol :

body (replace-regexp-in-string
                "\\\\{[^}]+}"
                (lambda (match)
                  (concat "#+BEGIN_EXAMPLE\n"
                          (substitute-command-keys match)
                          "#+END_EXAMPLE\n"))
                body t t)

aims to do two different things at once, namely enclosing strings like \\{yas-minor-mode-map} in an org-example block and substituting these strings with the pretty-formatted content of said minor mode map. It would be more robust to do only one of those things at a time, at a cost of a second parsing of the string. On top that, the very next block of the same function :

          body (substitute-command-keys body)

does the substitution on the whole block, which makes the form (substitute-command-keys match) in the previous block unneeded.

The change in commit c24c426 is therefore a simple fix to the documentation build failure, that does not change the output of the function yas--document-symbol.

(fix #1147)

Best,

Aymeric Agon-Rambosson

Command key substitution needs doing only once.

Repairs documentation building as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs fail to build with emacs 28
1 participant