aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-06-27 21:52:38 -0400
committerStefan Monnier2014-06-27 21:52:38 -0400
commitb1c4d6861e0f1e84c37c3df034b1f6d6dea7dcbf (patch)
treefaf3e21f6e7d714295e18272401227fa58ae0932
parentf036e167feaf875873636972b28a4adc12c32254 (diff)
downloademacs-b1c4d6861e0f1e84c37c3df034b1f6d6dea7dcbf.tar.gz
emacs-b1c4d6861e0f1e84c37c3df034b1f6d6dea7dcbf.zip
* lisp/progmodes/hideif.el: Use lexical-binding. Fix up cl-lib usage.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/progmodes/hideif.el51
2 files changed, 28 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dac472664f1..15b1a38e820 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12014-06-28 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/hideif.el: Use lexical-binding. Fix up cl-lib usage.
4
12014-06-28 K. Handa <handa@gnu.org> 52014-06-28 K. Handa <handa@gnu.org>
2 6
3 Fix Bug#17739. 7 Fix Bug#17739.
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index 4b78c08690a..6585668b927 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -1,4 +1,4 @@
1;;; hideif.el --- hides selected code within ifdef 1;;; hideif.el --- hides selected code within ifdef -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1988, 1994, 2001-2014 Free Software Foundation, Inc. 3;; Copyright (C) 1988, 1994, 2001-2014 Free Software Foundation, Inc.
4 4
@@ -550,8 +550,8 @@ that form should be displayed.")
550 (setq tok (cadr tokens)) 550 (setq tok (cadr tokens))
551 (if (eq (car tokens) 'hif-lparen) 551 (if (eq (car tokens) 'hif-lparen)
552 (if (and (hif-if-valid-identifier-p tok) 552 (if (and (hif-if-valid-identifier-p tok)
553 (eq (caddr tokens) 'hif-rparen)) 553 (eq (cl-caddr tokens) 'hif-rparen))
554 (setq tokens (cdddr tokens)) 554 (setq tokens (cl-cdddr tokens))
555 (error "#define followed by non-identifier: %S" tok)) 555 (error "#define followed by non-identifier: %S" tok))
556 (setq tok (car tokens) 556 (setq tok (car tokens)
557 tokens (cdr tokens)) 557 tokens (cdr tokens))
@@ -607,9 +607,8 @@ detecting self-reference."
607 ;; for hif-macro-supply-arguments 607 ;; for hif-macro-supply-arguments
608 (let* ((hif-token-list (cdr remains)) 608 (let* ((hif-token-list (cdr remains))
609 (hif-token nil) 609 (hif-token nil)
610 (parmlist (mapcar 'hif-expand-token-list 610 (parmlist (mapcar #'hif-expand-token-list
611 (hif-get-argument-list 611 (hif-get-argument-list)))
612 tok)))
613 (result 612 (result
614 (hif-expand-token-list 613 (hif-expand-token-list
615 (hif-macro-supply-arguments tok parmlist) 614 (hif-macro-supply-arguments tok parmlist)
@@ -618,10 +617,10 @@ detecting self-reference."
618 result)) 617 result))
619 ;; Argument list is nil, direct expansion 618 ;; Argument list is nil, direct expansion
620 (setq rep (hif-expand-token-list 619 (setq rep (hif-expand-token-list
621 (caddr rep) ; Macro's token list 620 (cl-caddr rep) ; Macro's token list
622 tok expand_list)) 621 tok expand_list))
623 ;; Replace all remaining references immediately 622 ;; Replace all remaining references immediately
624 (setq remains (substitute tok rep remains)) 623 (setq remains (cl-substitute tok rep remains))
625 rep) 624 rep)
626 ;; Lookup tok returns an atom 625 ;; Lookup tok returns an atom
627 rep)) 626 rep))
@@ -824,7 +823,7 @@ factor : '!' factor | '~' factor | '(' expr ')' | 'defined(' id ')' |
824 (hif-place-macro-invocation ident) 823 (hif-place-macro-invocation ident)
825 `(hif-lookup (quote ,ident))))))) 824 `(hif-lookup (quote ,ident)))))))
826 825
827(defun hif-get-argument-list (ident) 826(defun hif-get-argument-list ()
828 (let ((nest 0) 827 (let ((nest 0)
829 (parmlist nil) ; A "token" list of parameters, will later be parsed 828 (parmlist nil) ; A "token" list of parameters, will later be parsed
830 (parm nil)) 829 (parm nil))
@@ -849,7 +848,7 @@ factor : '!' factor | '~' factor | '(' expr ')' | 'defined(' id ')' |
849 (nreverse parmlist))) 848 (nreverse parmlist)))
850 849
851(defun hif-place-macro-invocation (ident) 850(defun hif-place-macro-invocation (ident)
852 (let ((parmlist (hif-get-argument-list ident))) 851 (let ((parmlist (hif-get-argument-list)))
853 `(hif-invoke (quote ,ident) (quote ,parmlist)))) 852 `(hif-invoke (quote ,ident) (quote ,parmlist))))
854 853
855(defun hif-string-concatenation () 854(defun hif-string-concatenation ()
@@ -861,7 +860,7 @@ factor : '!' factor | '~' factor | '(' expr ')' | 'defined(' id ')' |
861 (substring hif-token 1)))) ; remove leading '"' 860 (substring hif-token 1)))) ; remove leading '"'
862 result)) 861 result))
863 862
864(defun hif-define-macro (parmlist token-body) 863(defun hif-define-macro (_parmlist _token-body)
865 "A marker for defined macro with arguments. 864 "A marker for defined macro with arguments.
866This macro cannot be evaluated alone without parameters inputed." 865This macro cannot be evaluated alone without parameters inputed."
867 ;;TODO: input arguments at run time, use minibuffer to query all arguments 866 ;;TODO: input arguments at run time, use minibuffer to query all arguments
@@ -1002,8 +1001,8 @@ preprocessing token"
1002 result))) 1001 result)))
1003 1002
1004(defun hif-delimit (lis atom) 1003(defun hif-delimit (lis atom)
1005 (nconc (mapcan (lambda (l) (list l atom)) 1004 (nconc (cl-mapcan (lambda (l) (list l atom))
1006 (butlast lis)) 1005 (butlast lis))
1007 (last lis))) 1006 (last lis)))
1008 1007
1009;; Perform token replacement: 1008;; Perform token replacement:
@@ -1018,7 +1017,6 @@ preprocessing token"
1018 (macro-body (and macro (cadr macro))) 1017 (macro-body (and macro (cadr macro)))
1019 actual-count 1018 actual-count
1020 formal-count 1019 formal-count
1021 actual
1022 formal 1020 formal
1023 etc) 1021 etc)
1024 1022
@@ -1055,10 +1053,10 @@ preprocessing token"
1055 ;; Unlike `subst', `substitute' replace only the top level 1053 ;; Unlike `subst', `substitute' replace only the top level
1056 ;; instead of the whole tree; more importantly, it's not 1054 ;; instead of the whole tree; more importantly, it's not
1057 ;; destructive. 1055 ;; destructive.
1058 (substitute (if (and etc (null formal-parms)) 1056 (cl-substitute (if (and etc (null formal-parms))
1059 (hif-delimit actual-parms 'hif-comma) 1057 (hif-delimit actual-parms 'hif-comma)
1060 (car actual-parms)) 1058 (car actual-parms))
1061 formal macro-body)) 1059 formal macro-body))
1062 (setq actual-parms (cdr actual-parms))) 1060 (setq actual-parms (cdr actual-parms)))
1063 1061
1064 ;; Replacement completed, flatten the whole token list 1062 ;; Replacement completed, flatten the whole token list
@@ -1462,7 +1460,6 @@ first arg will be `hif-etc'."
1462 (let* ((defining (string= "define" (match-string 2))) 1460 (let* ((defining (string= "define" (match-string 2)))
1463 (name (and (re-search-forward hif-macroref-regexp max t) 1461 (name (and (re-search-forward hif-macroref-regexp max t)
1464 (match-string 1))) 1462 (match-string 1)))
1465 (parsed nil)
1466 (parmlist (and (match-string 3) ; First arg id found 1463 (parmlist (and (match-string 3) ; First arg id found
1467 (hif-parse-macro-arglist (match-string 2))))) 1464 (hif-parse-macro-arglist (match-string 2)))))
1468 (if defining 1465 (if defining
@@ -1534,15 +1531,15 @@ It does not do the work that's pointless to redo on a recursive entry."
1534 (save-excursion 1531 (save-excursion
1535 (let ((case-fold-search nil) 1532 (let ((case-fold-search nil)
1536 min max) 1533 min max)
1537 (goto-char (point-min)) 1534 (goto-char (point-min))
1538 (setf min (point)) 1535 (setf min (point))
1539 (loop do 1536 (cl-loop do
1540 (setf max (hif-find-any-ifX)) 1537 (setf max (hif-find-any-ifX))
1541 (hif-add-new-defines min max) 1538 (hif-add-new-defines min max)
1542 (if max 1539 (if max
1543 (hif-possibly-hide)) 1540 (hif-possibly-hide))
1544 (setf min (point)) 1541 (setf min (point))
1545 while max)))) 1542 while max))))
1546 1543
1547;;===%%SF%% hide-ifdef-hiding (End) === 1544;;===%%SF%% hide-ifdef-hiding (End) ===
1548 1545