1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Prefer incf to cl-incf in progmodes/*.el

* lisp/progmodes/bug-reference.el (bug-reference--overlay-bounds):
* lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset):
* lisp/progmodes/compile.el (compilation--note-type):
* lisp/progmodes/ebrowse.el (ebrowse-files-table)
(ebrowse-fill-member-table, ebrowse-find-pattern)
(ebrowse-draw-member-short-fn, ebrowse-gather-statistics):
* lisp/progmodes/elixir-ts-mode.el
(elixir-ts--electric-pair-string-delimiter):
* lisp/progmodes/gdb-mi.el (gdb-thread-list-handler-custom):
* lisp/progmodes/grep.el (grep-filter):
* lisp/progmodes/hideif.el (hif-backward-comment, hif-__COUNTER__)
(hif-token-concatenation, hif-find-define):
* lisp/progmodes/js.el (js--pstate-is-toplevel-defun)
(js-beginning-of-defun, js-end-of-defun, js--pitems-to-imenu)
(js--imenu-to-flat, js-ts--syntax-propertize):
* lisp/progmodes/tcl.el (tcl--syntax-of-quote):
* lisp/progmodes/typescript-ts-mode.el
(tsx-ts--syntax-propertize-captures): Prefer incf to cl-incf.
This commit is contained in:
Stefan Kangas 2025-02-25 08:28:30 +01:00
parent 99d116a8f4
commit d1d85e0f35
11 changed files with 36 additions and 36 deletions

View file

@ -138,7 +138,7 @@ to the highlighted and clickable region."
(or (< (match-beginning i) m-b1) (or (< (match-beginning i) m-b1)
(> (match-end i) m-e1))) (> (match-end i) m-e1)))
(throw 'within-bounds nil)) (throw 'within-bounds nil))
(cl-incf i)) (incf i))
t))) t)))
;; All groups 2..10 are within bounds. ;; All groups 2..10 are within bounds.
(cons m-b1 m-e1) (cons m-b1 m-e1)

View file

@ -503,7 +503,7 @@ characters on the current line."
(let ((parent (treesit-node-parent node))) (let ((parent (treesit-node-parent node)))
;; Increment level for every bracket (with exception). ;; Increment level for every bracket (with exception).
(when (c-ts-common--node-is node 'block) (when (c-ts-common--node-is node 'block)
(cl-incf level) (incf level)
(save-excursion (save-excursion
(goto-char (treesit-node-start node)) (goto-char (treesit-node-start node))
;; Add an extra level if the opening bracket is on its own ;; Add an extra level if the opening bracket is on its own
@ -515,12 +515,12 @@ characters on the current line."
;; Add a level. ;; Add a level.
((looking-back (rx bol (* whitespace)) ((looking-back (rx bol (* whitespace))
(line-beginning-position)) (line-beginning-position))
(cl-incf level))))) (incf level)))))
;; Fix bracketless statements. ;; Fix bracketless statements.
(when (and (c-ts-common--node-is parent (when (and (c-ts-common--node-is parent
'if 'do 'while 'for) 'if 'do 'while 'for)
(not (c-ts-common--node-is node 'block))) (not (c-ts-common--node-is node 'block)))
(cl-incf level)) (incf level))
;; Flatten "else if" statements. ;; Flatten "else if" statements.
(when (and (c-ts-common--node-is node 'else) (when (and (c-ts-common--node-is node 'else)
(c-ts-common--node-is node 'if) (c-ts-common--node-is node 'if)

View file

@ -1641,9 +1641,9 @@ RULE is the name (symbol) of the rule used or nil if anonymous.
"Note that a new message with severity TYPE was seen. "Note that a new message with severity TYPE was seen.
This updates the appropriate variable used by the mode-line." This updates the appropriate variable used by the mode-line."
(cl-case type (cl-case type
(0 (cl-incf compilation-num-infos-found)) (0 (incf compilation-num-infos-found))
(1 (cl-incf compilation-num-warnings-found)) (1 (incf compilation-num-warnings-found))
(2 (cl-incf compilation-num-errors-found)))) (2 (incf compilation-num-errors-found))))
(defun compilation-parse-errors (start end &rest rules) (defun compilation-parse-errors (start end &rest rules)
"Parse errors between START and END. "Parse errors between START and END.

View file

@ -593,7 +593,7 @@ MARKED-ONLY non-nil means include marked classes only."
(ebrowse-for-all-trees (tree ebrowse--tree-table) (ebrowse-for-all-trees (tree ebrowse--tree-table)
(when (or (not marked-only) (ebrowse-ts-mark tree)) (when (or (not marked-only) (ebrowse-ts-mark tree))
(let ((class (ebrowse-ts-class tree))) (let ((class (ebrowse-ts-class tree)))
(when (zerop (% (cl-incf i) 20)) (when (zerop (% (incf i) 20))
(ebrowse-show-progress "Preparing file list" (zerop i))) (ebrowse-show-progress "Preparing file list" (zerop i)))
;; Add files mentioned in class description ;; Add files mentioned in class description
(let ((source-file (ebrowse-cs-source-file class)) (let ((source-file (ebrowse-cs-source-file class))
@ -864,7 +864,7 @@ type `ebrowse-hs' is set to the resulting table."
(garbage-collect) (garbage-collect)
;; For all classes... ;; For all classes...
(ebrowse-for-all-trees (c ebrowse--tree-table) (ebrowse-for-all-trees (c ebrowse--tree-table)
(when (zerop (% (cl-incf i) 10)) (when (zerop (% (incf i) 10))
(ebrowse-show-progress "Preparing member lookup" (zerop i))) (ebrowse-show-progress "Preparing member lookup" (zerop i)))
(dolist (f ebrowse-member-list-accessors) (dolist (f ebrowse-member-list-accessors)
(dolist (m (funcall f c)) (dolist (m (funcall f c))
@ -1649,7 +1649,7 @@ INFO is a list (TREE-HEADER TREE-OR-MEMBER MEMBER-LIST)."
when (re-search-forward pattern (+ start offset) t) when (re-search-forward pattern (+ start offset) t)
return t return t
never (bobp) never (bobp)
do (cl-incf offset offset))) do (incf offset offset)))
(cond (found (cond (found
(beginning-of-line) (beginning-of-line)
(run-hooks 'ebrowse-view/find-hook)) (run-hooks 'ebrowse-view/find-hook))
@ -2689,7 +2689,7 @@ TREE is the class tree in which the members are found."
mouse-face highlight mouse-face highlight
ebrowse-tree ,tree ebrowse-tree ,tree
help-echo "mouse-2: view definition; mouse-3: menu")) help-echo "mouse-2: view definition; mouse-3: menu"))
(cl-incf i) (incf i)
(when (>= i ebrowse--n-columns) (when (>= i ebrowse--n-columns)
(setf i 0) (setf i 0)
(insert "\n"))))) (insert "\n")))))
@ -4032,11 +4032,11 @@ NUMBER-OF-STATIC-VARIABLES:"
(let ((classes 0) (member-functions 0) (member-variables 0) (let ((classes 0) (member-functions 0) (member-variables 0)
(static-functions 0) (static-variables 0)) (static-functions 0) (static-variables 0))
(ebrowse-for-all-trees (tree ebrowse--tree-table) (ebrowse-for-all-trees (tree ebrowse--tree-table)
(cl-incf classes) (incf classes)
(cl-incf member-functions (length (ebrowse-ts-member-functions tree))) (incf member-functions (length (ebrowse-ts-member-functions tree)))
(cl-incf member-variables (length (ebrowse-ts-member-variables tree))) (incf member-variables (length (ebrowse-ts-member-variables tree)))
(cl-incf static-functions (length (ebrowse-ts-static-functions tree))) (incf static-functions (length (ebrowse-ts-static-functions tree)))
(cl-incf static-variables (length (ebrowse-ts-static-variables tree)))) (incf static-variables (length (ebrowse-ts-static-variables tree))))
(list classes member-functions member-variables (list classes member-functions member-variables
static-functions static-variables))) static-functions static-variables)))

View file

@ -658,7 +658,7 @@ Return nil if NODE is not a defun node or doesn't have a name."
(eq last-command-event ?\") (eq last-command-event ?\")
(let ((count 0)) (let ((count 0))
(while (eq (char-before (- (point) count)) last-command-event) (while (eq (char-before (- (point) count)) last-command-event)
(cl-incf count)) (incf count))
(= count 3)) (= count 3))
(eq (char-after) last-command-event)) (eq (char-after) last-command-event))
(save-excursion (save-excursion

View file

@ -3545,7 +3545,7 @@ corresponding to the mode line clicked."
(add-to-list 'gdb-threads-list (add-to-list 'gdb-threads-list
(cons (gdb-mi--field thread 'id) (cons (gdb-mi--field thread 'id)
thread)) thread))
(cl-incf (if running (incf (if running
gdb-running-threads-count gdb-running-threads-count
gdb-stopped-threads-count)) gdb-stopped-threads-count))

View file

@ -648,7 +648,7 @@ This function is called from `compilation-filter-hook'."
(replace-match (propertize (match-string 1) (replace-match (propertize (match-string 1)
'face nil 'font-lock-face grep-match-face) 'face nil 'font-lock-face grep-match-face)
t t) t t)
(cl-incf grep-num-matches-found)) (incf grep-num-matches-found))
;; Delete all remaining escape sequences ;; Delete all remaining escape sequences
(goto-char beg) (goto-char beg)
(while (re-search-forward "\033\\[[0-9;]*[mK]" end 1) (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1)

View file

@ -888,7 +888,7 @@ Assuming we've just performed a `hif-token-regexp' lookup."
;; merge whites immediately ahead ;; merge whites immediately ahead
(setq ce (if (and we (= (1- p) we)) ws p)) (setq ce (if (and we (= (1- p) we)) ws p))
;; scan for end of line ;; scan for end of line
(while (and (< (cl-incf p) end) (while (and (< (incf p) end)
(not (char-equal ?\n (char-after p))) (not (char-equal ?\n (char-after p)))
(not (char-equal ?\r (char-after p))))) (not (char-equal ?\r (char-after p)))))
;; Merge with previous comment if immediately followed ;; Merge with previous comment if immediately followed
@ -913,7 +913,7 @@ Assuming we've just performed a `hif-token-regexp' lookup."
(while (< (1+ p) end) (while (< (1+ p) end)
(if (not (and (char-equal ?* (char-after p)) (if (not (and (char-equal ?* (char-after p))
(char-equal ?/ (char-after (1+ p))))) (char-equal ?/ (char-after (1+ p)))))
(cl-incf p) (incf p)
;; found `*/', mark end pos ;; found `*/', mark end pos
(push (cons cmt (1+ (setq p (1+ p)))) cmtlist) (push (cons cmt (1+ (setq p (1+ p)))) cmtlist)
(throw 'break nil))) (throw 'break nil)))
@ -927,7 +927,7 @@ Assuming we've just performed a `hif-token-regexp' lookup."
we p)) we p))
(setq ws nil (setq ws nil
we nil))) we nil)))
(cl-incf p)) (incf p))
;; Goto beginning of the last comment, if we're within ;; Goto beginning of the last comment, if we're within
(setq cmt (car cmtlist)) ;; last cmt (setq cmt (car cmtlist)) ;; last cmt
(setq cmt (if (and cmt (setq cmt (if (and cmt
@ -1531,7 +1531,7 @@ and `+='...)."
(defvar hif-__COUNTER__ 0) (defvar hif-__COUNTER__ 0)
(defun hif-__COUNTER__ () (defun hif-__COUNTER__ ()
(prog1 hif-__COUNTER__ (cl-incf hif-__COUNTER__))) (prog1 hif-__COUNTER__ (incf hif-__COUNTER__)))
(defun hif-__cplusplus () (defun hif-__cplusplus ()
(and (string-match (and (string-match
@ -1604,7 +1604,7 @@ and `+='...)."
(push tk items) ; first item, in reverse order (push tk items) ; first item, in reverse order
(setq tk 'hif-token-concat)) (setq tk 'hif-token-concat))
(while (eq tk 'hif-token-concat) (while (eq tk 'hif-token-concat)
(cl-incf count) (incf count)
;; 2+ item ;; 2+ item
(setq l (cdr l) (setq l (cdr l)
tk (car l)) tk (car l))
@ -2477,7 +2477,7 @@ first arg will be `hif-etc'."
(tokens (tokens
(and name (and name
(prog1 t (prog1 t
(cl-incf hif-verbose-define-count) (incf hif-verbose-define-count)
;; only show 1/50 to not slow down to much ;; only show 1/50 to not slow down to much
(if (and hide-ifdef-verbose (if (and hide-ifdef-verbose
(= (% hif-verbose-define-count 50) 1)) (= (% hif-verbose-define-count 50) 1))

View file

@ -982,7 +982,7 @@ top-most pitem. Otherwise, return nil."
with func-depth = 0 with func-depth = 0
with func-pitem with func-pitem
if (eq 'function (js--pitem-type pitem)) if (eq 'function (js--pitem-type pitem))
do (cl-incf func-depth) do (incf func-depth)
and do (setq func-pitem pitem) and do (setq func-pitem pitem)
finally return (if (eq func-depth 1) func-pitem))) finally return (if (eq func-depth 1) func-pitem)))
@ -1017,7 +1017,7 @@ Return the pitem of the function we went to the beginning of."
(setq arg (or arg 1)) (setq arg (or arg 1))
(let ((found)) (let ((found))
(while (and (not (eobp)) (< arg 0)) (while (and (not (eobp)) (< arg 0))
(cl-incf arg) (incf arg)
(when (and (not js-flat-functions) (when (and (not js-flat-functions)
(or (eq (js-syntactic-context) 'function) (or (eq (js-syntactic-context) 'function)
(js--function-prologue-beginning))) (js--function-prologue-beginning)))
@ -1360,7 +1360,7 @@ LIMIT defaults to point."
"Value of `end-of-defun-function' for `js-mode'." "Value of `end-of-defun-function' for `js-mode'."
(setq arg (or arg 1)) (setq arg (or arg 1))
(while (and (not (bobp)) (< arg 0)) (while (and (not (bobp)) (< arg 0))
(cl-incf arg) (incf arg)
(js-beginning-of-defun) (js-beginning-of-defun)
(js-beginning-of-defun) (js-beginning-of-defun)
(unless (bobp) (unless (bobp)
@ -3180,7 +3180,7 @@ the broken-down class name of the item to insert."
(setq pitem-name (js--pitem-strname pitem)) (setq pitem-name (js--pitem-strname pitem))
(when (eq pitem-name t) (when (eq pitem-name t)
(setq pitem-name (format "[unknown %s]" (setq pitem-name (format "[unknown %s]"
(cl-incf (car unknown-ctr))))) (incf (car unknown-ctr)))))
(cond (cond
((memq pitem-type '(function macro)) ((memq pitem-type '(function macro))
@ -3255,7 +3255,7 @@ the broken-down class name of the item to insert."
(ctr 0)) (ctr 0))
(while (gethash name2 symbols) (while (gethash name2 symbols)
(setq name2 (format "%s<%d>" name (cl-incf ctr)))) (setq name2 (format "%s<%d>" name (incf ctr))))
(puthash name2 (cdr item) symbols)))) (puthash name2 (cdr item) symbols))))
@ -4037,7 +4037,7 @@ See `treesit-thing-settings' for more information.")
(syntax (pcase-exhaustive name (syntax (pcase-exhaustive name
('regexp ('regexp
(decf ns) (decf ns)
(cl-incf ne) (incf ne)
(string-to-syntax "\"/")) (string-to-syntax "\"/"))
('jsx ('jsx
(string-to-syntax "|"))))) (string-to-syntax "|")))))

View file

@ -432,9 +432,9 @@ This variable is generally set from `tcl-proc-regexp',
(pcase (char-after (match-beginning 0)) (pcase (char-after (match-beginning 0))
(?\\ (forward-char 1)) (?\\ (forward-char 1))
(?\" (setq type 'matched)) (?\" (setq type 'matched))
(?\{ (cl-incf depth)) (?\{ (incf depth))
(?\} (if (zerop depth) (setq type 'unmatched) (?\} (if (zerop depth) (setq type 'unmatched)
(cl-incf depth))))) (incf depth)))))
(when (> (line-beginning-position) pos) (when (> (line-beginning-position) pos)
;; The quote is not on the same line as the deciding ;; The quote is not on the same line as the deciding
;; factor, so make sure we revisit this choice later. ;; factor, so make sure we revisit this choice later.

View file

@ -680,7 +680,7 @@ at least 3 (which is the default value)."
('regexp ('regexp
(let ((syntax (string-to-syntax "\"/"))) (let ((syntax (string-to-syntax "\"/")))
(decf ns) (decf ns)
(cl-incf ne) (incf ne)
(put-text-property ns (1+ ns) 'syntax-table syntax) (put-text-property ns (1+ ns) 'syntax-table syntax)
(put-text-property (1- ne) ne 'syntax-table syntax))) (put-text-property (1- ne) ne 'syntax-table syntax)))
;; We put punctuation syntax on all the balanced pair ;; We put punctuation syntax on all the balanced pair