bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67795: [PATCH] Handle local-variable major-mode remaps specifying no


From: Stefan Monnier
Subject: bug#67795: [PATCH] Handle local-variable major-mode remaps specifying non-existent mode
Date: Tue, 05 Mar 2024 01:28:31 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

OK, I had another look at the problem.

For `hack-local-variables--find-variables` I still don't really
understand why we need this (eq handle-mode t) functionality
of the function, so maybe I missed a better way to fix the problem, but
the proposed hunk looks OK, tho it need to be updated to account for
recent changes in `master`.  The new hunk would look like:

    @@ -4235,7 +4241,7 @@ hack-local-variables--find-variables
                (forward-line 1)))))))
         (if (eq handle-mode t)
             ;; Return the final mode: setting that's defined.
    -        (car (seq-filter #'fboundp result))
    +        (car (seq-filter (lambda (mode) (fboundp (major-mode-remap mode))) 
result))
           result)))
     
     (defun hack-local-variables-apply ()

Tho the code can be streamlined a bit so as not to create a list only to
select its first element:

    @@ -4201,8 +4207,9 @@ hack-local-variables--find-variables
                               (not (string-match
                                     "-minor\\'"
                                     (setq val2 (downcase (symbol-name val)))))
    -                           ;; Allow several mode: elements.
    -                           (push (intern (concat val2 "-mode")) result))
    +                          (let ((mode (intern (concat val2 "-mode"))))
    +                             (when (fboundp (major-mode-remap mode))
    +                               (setq result mode))))
                        (cond ((eq var 'coding))
                              ((eq var 'lexical-binding)
                               (unless hack-local-variables--warned-lexical
    @@ -4233,10 +4240,7 @@ hack-local-variables--find-variables
                                             val)
                                        result))))))
                    (forward-line 1)))))))
    -    (if (eq handle-mode t)
    -        ;; Return the final mode: setting that's defined.
    -        (car (seq-filter #'fboundp result))
    -      result)))
    +    result))
     
     (defun hack-local-variables-apply ()
       "Apply the elements of `file-local-variables-alist'.

Any comment/objection on this part?


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]