Skip to content

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

aagon added 2 commits January 2, 2023 14:56
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