master e2abbab680d: Add safeguard to 'set-variable' (bug#81244)

Juri Linkov <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit e2abbab680ddce6326ab7f8892e93d32acdcd3b9
Author: Juri Linkov <[email protected]>
Commit: Juri Linkov <[email protected]>

    Add safeguard to 'set-variable' (bug#81244)
    
    * lisp/simple.el (set-variable): Add check with 'boundp'
    before using 'symbol-value'.  This helps in rare cases
    when used on an undefined variable name.
---
 lisp/simple.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index fd9ba28c762..d92abe331c8 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10025,10 +10025,12 @@ makes it easier to edit it."
                      (call-interactively `(lambda (arg)
                                             (interactive ,prop)
                                             arg))
-                   (read-from-minibuffer prompt nil
-                                         read-expression-map t
-                                         'set-variable-value-history
-                                         (format "%S" (symbol-value var)))))))
+                   (read-from-minibuffer
+                    prompt nil
+                    read-expression-map t
+                    'set-variable-value-history
+                    (when (boundp var)
+                      (format "%S" (symbol-value var))))))))
      (list var val current-prefix-arg)))
 
   (and (custom-variable-p variable)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.