From 63b5a4a65eec5792b985c9d6be68424731bd478d Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Tue, 8 Aug 2017 15:10:49 -0400 Subject: [PATCH] Replace some uses of eval There are a number of places where eval is used unnecessarily to get or set the value of a symbol. * lisp/calendar/calendar.el (diary-date-forms): Use default-value in custom setter. * lisp/desktop.el (desktop-clear): Use set-default instead. * lisp/international/ogonek.el (ogonek-read-encoding): Use symbol-value. --- lisp/calendar/calendar.el | 2 +- lisp/desktop.el | 4 ++-- lisp/international/ogonek.el | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 84282209ddd..1d6749319d8 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -835,7 +835,7 @@ For examples of three common styles, see `diary-american-date-forms', diary-american-date-forms) :initialize 'custom-initialize-default :set (lambda (symbol value) - (unless (equal value (eval symbol)) + (unless (equal value (default-value symbol)) (custom-set-default symbol value) (setq diary-font-lock-keywords (diary-font-lock-keywords)) ;; Need to redraw not just to get new font-locking, but also diff --git a/lisp/desktop.el b/lisp/desktop.el index 540d0e3b11d..a2260ba490d 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -709,8 +709,8 @@ if different)." (setq desktop-io-file-version nil) (dolist (var desktop-globals-to-clear) (if (symbolp var) - (eval `(setq-default ,var nil)) - (eval `(setq-default ,(car var) ,(cdr var))))) + (set-default var nil) + (set-default var (eval (cdr var))))) (let ((preserve-regexp (concat "^\\(" (mapconcat (lambda (regexp) (concat "\\(" regexp "\\)")) diff --git a/lisp/international/ogonek.el b/lisp/international/ogonek.el index ef3a980f19a..cabcf90078a 100644 --- a/lisp/international/ogonek.el +++ b/lisp/international/ogonek.el @@ -301,13 +301,12 @@ Store the name in the parameter-variable DEFAULT-NAME-VAR. PROMPT is a string to be shown when the user is asked for a name." (let ((encoding (completing-read - (format "%s (default %s): " prompt (eval default-name-var)) + (format "%s (default %s): " prompt (symbol-value default-name-var)) ogonek-name-encoding-alist nil t))) - ;; change the default name to the one just read - (set default-name-var - (if (string= encoding "") (eval default-name-var) encoding)) + ;; change the default name to the one just read, and ;; return the new default as the name you read - (eval default-name-var))) + (set default-name-var + (if (string= encoding "") (symbol-value default-name-var) encoding)))) (defun ogonek-read-prefix (prompt default-prefix-var) "Read a prefix character for prefix notation. -- 2.39.5