]> git.eshelyaron.com Git - emacs.git/commitdiff
hideif.el: Minor cleanup
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 14 Feb 2024 01:35:05 +0000 (20:35 -0500)
committerEshel Yaron <me@eshelyaron.com>
Wed, 14 Feb 2024 08:17:01 +0000 (09:17 +0100)
* lisp/progmodes/hideif.el: Prefer #' to quote function names.
(hif-eval): Use `lexical-binding`.
(hif-ifx-regexp): Don't use `defconst` since `bovine/c.el` let-binds it.
(hif--intern-safe): Rename from `intern-safe` to fix this
namespace violation.
(hif-strtok): Adjust accordingly.

(cherry picked from commit 70d6f6c41c9b1985e0ec70b45aeeac6982a050bb)

lisp/progmodes/hideif.el

index 71f55379d9622d74ef1a1d06709e59ca5bf275bd..98e567299a1ce32de0dd94369d6b415b29f37da4 100644 (file)
@@ -390,7 +390,7 @@ If there is a marked region from START to END it only shows the symbols within."
 (defun hif-after-revert-function ()
   (and hide-ifdef-mode hide-ifdef-hiding
        (hide-ifdefs nil nil t)))
-(add-hook 'after-revert-hook 'hif-after-revert-function)
+(add-hook 'after-revert-hook #'hif-after-revert-function)
 
 (defun hif-end-of-line ()
   "Find the end-point of line concatenation."
@@ -474,7 +474,7 @@ Everything including these lines is made invisible."
 
 (defun hif-eval (form)
   "Evaluate hideif internal representation."
-  (let ((val (eval form)))
+  (let ((val (eval form t)))
     (if (stringp val)
         (or (get-text-property 0 'hif-value val)
             val)
@@ -542,7 +542,7 @@ that form should be displayed.")
 (defconst hif-cpp-prefix      "\\(^\\|\r\\)?[ \t]*#[ \t]*")
 (defconst hif-ifxdef-regexp   (concat hif-cpp-prefix "if\\(n\\)?def"))
 (defconst hif-ifndef-regexp   (concat hif-cpp-prefix "ifndef"))
-(defconst hif-ifx-regexp      (concat hif-cpp-prefix "if\\((\\|\\(n?def\\)?[ \t]+\\)"))
+(defvar hif-ifx-regexp      (concat hif-cpp-prefix "if\\((\\|\\(n?def\\)?[ \t]+\\)"))
 (defconst hif-elif-regexp     (concat hif-cpp-prefix "elif"))
 (defconst hif-else-regexp     (concat hif-cpp-prefix "else"))
 (defconst hif-endif-regexp    (concat hif-cpp-prefix "endif"))
@@ -679,7 +679,7 @@ that form should be displayed.")
     ("..." . hif-etc)
     ("defined" . hif-defined)))
 
-(defconst hif-valid-token-list (mapcar 'cdr hif-token-alist))
+(defconst hif-valid-token-list (mapcar #'cdr hif-token-alist))
 
 (defconst hif-token-regexp
   ;; The ordering of regexp grouping is crucial to `hif-strtok'
@@ -690,7 +690,7 @@ that form should be displayed.")
    ;; decimal/octal:
    "\\|\\(\\([+-]?[0-9']+\\(\\.[0-9']*\\)?\\)\\([eE][+-]?[0-9]+\\)?"
    hif-numtype-suffix-regexp "?\\)"
-   "\\|" (regexp-opt (mapcar 'car hif-token-alist) t)
+   "\\|" (regexp-opt (mapcar #'car hif-token-alist) t)
    "\\|\\(\\w+\\)"))
 
 ;; C++11 Unicode string literals (L"" u8"" u"" U"" R"" LR"" u8R"" uR"")
@@ -867,7 +867,7 @@ Assuming we've just performed a `hif-token-regexp' lookup."
 
      (t
       (setq hif-simple-token-only nil)
-      (intern-safe string)))))
+      (hif--intern-safe string)))))
 
 (defun hif-backward-comment (&optional start end)
   "If we're currently within a C(++) comment, skip them backwards."
@@ -1448,7 +1448,7 @@ This macro cannot be evaluated alone without parameters input."
    (t
     (error "Invalid token to stringify"))))
 
-(defun intern-safe (str)
+(defun hif--intern-safe (str)
   (if (stringp str)
       (intern str)))