summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2024-10-12 21:59:36 +0200
committerUlrich Müller <ulm@gentoo.org>2024-10-12 21:59:36 +0200
commitef4912ca5fa4f759187dd8d82f55fb4264a8010d (patch)
tree6518c950c25a0d763943962be40d1a5b88d48a81
parentRemove fallback to profiles.desc (diff)
downloadebuild-mode-ef4912ca5fa4f759187dd8d82f55fb4264a8010d.tar.gz
ebuild-mode-ef4912ca5fa4f759187dd8d82f55fb4264a8010d.tar.bz2
ebuild-mode-ef4912ca5fa4f759187dd8d82f55fb4264a8010d.zip
Do not let-bind special variables
* ebuild-mode.el (ebuild-mode-tabify): Do not let-bind tabify-regexp because it is a special variable. (ebuild-run-command): Ditto for shell-command. * ebuild-mode.el: * glep-mode.el: * test/ebuild-mode-tests.el: Use unhyphenated names for lexical variables throughout, in order not to accidentally override any special variables. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r--ChangeLog11
-rw-r--r--ebuild-mode.el74
-rw-r--r--glep-mode.el6
-rw-r--r--test/ebuild-mode-tests.el28
4 files changed, 64 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d708a1..d69b2a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-10-12 Ulrich Müller <ulm@gentoo.org>
+
+ * ebuild-mode.el (ebuild-mode-tabify): Do not let-bind
+ tabify-regexp because it is a special variable.
+ (ebuild-run-command): Ditto for shell-command.
+ * ebuild-mode.el:
+ * glep-mode.el:
+ * test/ebuild-mode-tests.el: Use unhyphenated names for lexical
+ variables throughout, in order not to accidentally override any
+ special variables.
+
2024-10-08 Ulrich Müller <ulm@gentoo.org>
* ebuild-mode.el (ebuild-mode-arch-stable-list): Don't fall back
diff --git a/ebuild-mode.el b/ebuild-mode.el
index 9f4b3c2..27067a5 100644
--- a/ebuild-mode.el
+++ b/ebuild-mode.el
@@ -343,19 +343,17 @@ of the elements."
;; We cannot use the following since XEmacs doesn't support tabify-regexp.
;;(let ((tabify-regexp "^\t* [ \t]+"))
;; (tabify (point-min) (point-max)))
- (let ((tabify-regexp "^\t* [ \t]+")
- (indent-tabs-mode t))
+ (let ((indent-tabs-mode t))
(save-excursion
(goto-char (point-min))
- (while (re-search-forward tabify-regexp nil t)
- (let ((end-col (current-column))
- (beg-col (save-excursion (goto-char (match-beginning 0))
- (skip-chars-forward "\t")
- (current-column))))
- (if (= (/ end-col tab-width) (/ beg-col tab-width))
- nil
+ (while (re-search-forward "^\t* [ \t]+" nil t)
+ (let ((end (current-column))
+ (beg (save-excursion (goto-char (match-beginning 0))
+ (skip-chars-forward "\t")
+ (current-column))))
+ (unless (= (/ end tab-width) (/ beg tab-width))
(delete-region (match-beginning 0) (point))
- (indent-to end-col)))))))
+ (indent-to end)))))))
(defun ebuild-mode-delete-trailing-whitespace ()
"Delete all the trailing spaces and tabs across the current buffer."
@@ -378,12 +376,12 @@ of the elements."
(save-excursion
(goto-char (point-min))
(let ((case-fold-search nil)
- (update-year (or (nlistp ebuild-mode-update-copyright)
- (nth 0 ebuild-mode-update-copyright)))
- (update-author (or (nlistp ebuild-mode-update-copyright)
- (nth 1 ebuild-mode-update-copyright))))
+ (updyear (or (nlistp ebuild-mode-update-copyright)
+ (nth 0 ebuild-mode-update-copyright)))
+ (updauth (or (nlistp ebuild-mode-update-copyright)
+ (nth 1 ebuild-mode-update-copyright))))
(when (re-search-forward ebuild-mode-copyright-regexp 400 t)
- (if update-year
+ (if updyear
(save-match-data
(let* ((y1 (string-to-number (match-string 1)))
(y2 (and (match-string 2)
@@ -406,7 +404,7 @@ of the elements."
"Suspicious copyright year: %d" y1))
((/= y1 y)
(replace-match (concat "\\1-" year) t nil nil 1)))))))
- (if update-author
+ (if updauth
;; Update default author in copyright notice
(if (string-equal (match-string 3) "Gentoo Foundation")
(replace-match "Gentoo Authors" t t nil 3)))))))
@@ -467,14 +465,14 @@ If nil, `compilation-mode' will be used.")
(or buffer-file-name
(error "No file for this buffer"))
(let* ((file (file-relative-name buffer-file-name))
- (shell-command (format "ebuild %s %s" file command))
+ (cmd (format "ebuild %s %s" file command))
(process-environment (append ebuild-mode-process-environment
process-environment))
;;(compilation-mode-hook (lambda () (setq truncate-lines t)))
(compilation-buffer-name-function (lambda (_mode) "*ebuild*")))
(static-if (featurep 'xemacs)
- (compile shell-command)
- (compile shell-command ebuild-log-buffer-mode))))
+ (compile cmd)
+ (compile cmd ebuild-log-buffer-mode))))
;; Define functions for all ebuild subcommands
(dolist (command ebuild-commands-list)
@@ -639,13 +637,13 @@ sequences, instead of a simple double-quoted string.
This function supports only escape sequences that can occur in
the output of the \"declare -p\" Bash command."
(let ((case-fold-search nil)
- (decode-re (if ansi-c
- "\\\\\\([abtnvfreE\\'\"?]\\|[0-7]\\{1,3\\}\\)"
- "\\\\\\([$`\"\\\n]\\)"))
- (decode-alist '((?a . ?\a) (?b . ?\b) (?t . ?\t) (?n . ?\n) (?v . ?\v)
- (?f . ?\f) (?r . ?\r) (?e . ?\e) (?E . ?\e)))
+ (re (if ansi-c
+ "\\\\\\([abtnvfreE\\'\"?]\\|[0-7]\\{1,3\\}\\)"
+ "\\\\\\([$`\"\\\n]\\)"))
+ (map '((?a . ?\a) (?b . ?\b) (?t . ?\t) (?n . ?\n) (?v . ?\v)
+ (?f . ?\f) (?r . ?\r) (?e . ?\e) (?E . ?\e)))
i)
- (while (setq i (string-match decode-re s i))
+ (while (setq i (string-match re s i))
(let* ((m (match-string 1 s))
(c (aref m 0))
(byte (cond ((and (>= c ?0) (< c ?8))
@@ -654,7 +652,7 @@ the output of the \"declare -p\" Bash command."
(dotimes (j (length m))
(setq n (+ (* n 8) (- (aref m j) ?0))))
(logand n #xff)))
- ((cdr (assq c decode-alist)))
+ ((cdr (assq c map)))
(t c))))
(setq s (replace-match
(static-if (fboundp 'byte-to-string)
@@ -702,12 +700,12 @@ With prefix argument OTHER-WINDOW, visit the directory in another window."
"Visit the build log for the ebuild in this buffer.
With prefix argument OTHER-WINDOW, visit the directory in another window."
(interactive "P")
- (let ((build-log (concat (ebuild-mode-get-builddir) "/temp/build.log")))
- (unless (file-readable-p build-log)
- (error "Cannot read file \"%s\"" build-log))
+ (let ((file (concat (ebuild-mode-get-builddir) "/temp/build.log")))
+ (unless (file-readable-p file)
+ (error "Cannot read file \"%s\"" file))
(if other-window
- (find-file-other-window build-log)
- (find-file build-log))
+ (find-file-other-window file)
+ (find-file file))
;; decode ANSI SGR control sequences if possible (tty-format.el)
(and (assq 'ansi-colors format-alist)
(save-excursion
@@ -746,16 +744,16 @@ optional second argument NOERROR is non-nil."
(save-excursion
(goto-char (point-min))
(let ((case-fold-search nil)
- (kw-string (mapconcat
- (lambda (e) (concat (cdr e) (car e))) kw " ")))
+ (kwstring (mapconcat
+ (lambda (e) (concat (cdr e) (car e))) kw " ")))
(cond
((not (re-search-forward ebuild-mode-arch-regexp nil t))
(unless noerror (error "No KEYWORDS assignment found")))
((re-search-forward ebuild-mode-arch-regexp nil t)
(unless noerror (error "More than one KEYWORDS assignment found")))
(t
- (unless (string-equal kw-string (match-string 1))
- (replace-match kw-string t t nil 1)))))))
+ (unless (string-equal kwstring (match-string 1))
+ (replace-match kwstring t t nil 1)))))))
(defun ebuild-mode-modify-keywords (kw)
"Set keywords. KW is an alist of architectures and leaders."
@@ -763,12 +761,12 @@ optional second argument NOERROR is non-nil."
(dolist (k kw)
(let* ((arch (car k))
(leader (cdr k))
- (old-k (assoc arch keywords)))
+ (oldk (assoc arch keywords)))
(cond
;; remove keywords
((null leader)
(setq keywords (and (not (string-equal arch "all"))
- (delq old-k keywords))))
+ (delq oldk keywords))))
;; modify all non-masked keywords in the list
((string-equal arch "all")
(dolist (e keywords)
@@ -780,7 +778,7 @@ optional second argument NOERROR is non-nil."
ebuild-mode-arch-list))
(setcdr e leader))))
;; modify keyword
- (old-k (setcdr old-k leader))
+ (oldk (setcdr oldk leader))
;; add keyword
(t (setq keywords (cons k keywords))))))
(ebuild-mode-put-keywords
diff --git a/glep-mode.el b/glep-mode.el
index c80a9b4..48590a8 100644
--- a/glep-mode.el
+++ b/glep-mode.el
@@ -182,9 +182,9 @@ Calls the external \"glep\" command."
(interactive)
(or buffer-file-name
(error "No file for this buffer"))
- (let* ((rst-file (file-relative-name buffer-file-name))
- (html-file (concat (file-name-sans-extension rst-file) ".html")))
- (compile (format "glep %s %s" rst-file html-file))))
+ (let* ((src (file-relative-name buffer-file-name))
+ (dst (concat (file-name-sans-extension src) ".html")))
+ (compile (format "glep %s %s" src dst))))
;;; Skeleton support.
diff --git a/test/ebuild-mode-tests.el b/test/ebuild-mode-tests.el
index e3e39a7..d753a60 100644
--- a/test/ebuild-mode-tests.el
+++ b/test/ebuild-mode-tests.el
@@ -70,7 +70,7 @@
(let* ((alist '(((a b) z) ((c d) z) ((e) z) ((f) z) ((g h) z)
((i j) y x) ((k) y x) ((l)) ((m) z) ((n o) y x) ((p))
((q r s t u v) w)))
- (alist-copy (copy-tree alist)))
+ (alist1 (copy-tree alist)))
(should (equal (ebuild-mode-collect-and-split alist)
'(((a b c d e f g h m) z) ((i j k n o) y x) ((l p))
((q r s t u v) w))))
@@ -78,11 +78,11 @@
'(((a b c d) z) ((e f g h) z) ((i j k) y x) ((l p))
((m) z) ((n o) y x) ((q r s t) w) ((u v) w))))
;; was it non-destructive?
- (should (equal alist alist-copy))))
+ (should (equal alist alist1))))
(ert-deftest ebuild-mode-test-font-lock-keywords ()
(let ((case-fold-search nil)
- (find-kw (lambda (key)
+ (findkey (lambda (key)
(catch 'found
(dolist (e ebuild-mode-font-lock-keywords)
(if (string-match (car e) key)
@@ -94,10 +94,10 @@
(should (< (apply #'max (mapcar (lambda (e) (length (car e)))
ebuild-mode-font-lock-keywords))
32768))
- (should (equal (funcall find-kw "doins") 'font-lock-builtin-face))
- (should (equal (funcall find-kw "elisp-compile") 'font-lock-type-face))
- (should (equal (funcall find-kw "# @ECLASS") '(1 font-lock-type-face t)))
- (should-not (funcall find-kw "@ECLASS"))))
+ (should (equal (funcall findkey "doins") 'font-lock-builtin-face))
+ (should (equal (funcall findkey "elisp-compile") 'font-lock-type-face))
+ (should (equal (funcall findkey "# @ECLASS") '(1 font-lock-type-face t)))
+ (should-not (funcall findkey "@ECLASS"))))
(ert-deftest ebuild-mode-test-font-lock ()
(with-temp-buffer
@@ -265,9 +265,9 @@
(ert-deftest ebuild-mode-test-bug-url ()
(skip-unless (fboundp 'bug-reference-prog-mode))
(let* ((ebuild-mode-enable-bug-reference t)
- url-found
+ found
(browse-url-browser-function
- (lambda (url &rest _args) (setq url-found url))))
+ (lambda (url &rest _args) (setq found url))))
(with-temp-buffer
(insert "# abc #876543 xyz\n"
"# bug 765432\n")
@@ -277,15 +277,15 @@
(goto-char (point-min))
(search-forward "#" nil nil 2)
(bug-reference-push-button (point))
- (should (equal url-found "https://bugs.gentoo.org/876543"))
- (setq url-found nil)
+ (should (equal found "https://bugs.gentoo.org/876543"))
+ (setq found nil)
(search-forward "bug")
(bug-reference-push-button (point))
- (should (equal url-found "https://bugs.gentoo.org/765432"))
- (setq url-found nil)
+ (should (equal found "https://bugs.gentoo.org/765432"))
+ (setq found nil)
(bug-reference-push-button (point-min))
(bug-reference-push-button (point-max))
- (should-not url-found))))
+ (should-not found))))
(ert-deftest ebuild-mode-test-insert-tag-line ()
(let ((ebuild-mode-full-name "Larry the Cow")