aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-09-21 18:28:41 +0000
committerDave Love2000-09-21 18:28:41 +0000
commit80585273bd164c0eca43fc6225d43b326a9f27e2 (patch)
treef886773139745438016882ef835f0060ab7d78ab
parent6e4e8a3b59a7f81c0611bebf08e38f98b4d3f5a6 (diff)
downloademacs-80585273bd164c0eca43fc6225d43b326a9f27e2.tar.gz
emacs-80585273bd164c0eca43fc6225d43b326a9f27e2.zip
(top-level): Clean up
`eval-when-compile's and assorted defvars. (cperl-invalid-face): Don't double-quote value. Change custom type. (cperl-mode): Set normal-auto-fill-function and don't zap auto-fill-function. (cperl-imenu--function-name-regexp-perl): Renamed from imenu-example--function-name-regexp-perl. (cperl-imenu--create-perl-index): Renamed from imenu-example--create-perl-index. (cperl-xsub-scan): Don't require cl.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/cperl-mode.el211
2 files changed, 107 insertions, 116 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7f3d49ba90d..120a253520e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -22,6 +22,18 @@
22 22
232000-09-21 Dave Love <fx@gnu.org> 232000-09-21 Dave Love <fx@gnu.org>
24 24
25 * progmodes/cperl-mode.el (top-level): Clean up
26 `eval-when-compile's and assorted defvars.
27 (cperl-invalid-face): Don't double-quote value. Change custom
28 type.
29 (cperl-mode): Set normal-auto-fill-function and don't zap
30 auto-fill-function.
31 (cperl-imenu--function-name-regexp-perl): Renamed from
32 imenu-example--function-name-regexp-perl.
33 (cperl-imenu--create-perl-index): Renamed from
34 imenu-example--create-perl-index.
35 (cperl-xsub-scan): Don't require cl.
36
25 * msb.el (msb-mode-map): Use substitute-key-definition. 37 * msb.el (msb-mode-map): Use substitute-key-definition.
26 (msb-mode): Use msb-mode-map. 38 (msb-mode): Use msb-mode-map.
27 39
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index af66aa7fdd0..1bc03389181 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -63,49 +63,54 @@
63;;; Code: 63;;; Code:
64 64
65;; Some macros are needed for `defcustom' 65;; Some macros are needed for `defcustom'
66(if (fboundp 'eval-when-compile) 66(eval-when-compile
67 (eval-when-compile 67 (require 'font-lock)
68 (defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version)) 68 (defvar msb-menu-cond)
69 (defmacro cperl-is-face (arg) ; Takes quoted arg 69 (defvar gud-perldb-history)
70 (cond ((fboundp 'find-face) 70 (defvar font-lock-background-mode) ; not in Emacs
71 `(find-face ,arg)) 71 (defvar font-lock-display-type) ; ditto
72 (;;(and (fboundp 'face-list) 72 (defconst cperl-xemacs-p (string-match "XEmacs\\|Lucid" emacs-version))
73 ;; (face-list)) 73 (defmacro cperl-is-face (arg) ; Takes quoted arg
74 (fboundp 'face-list) 74 (cond ((fboundp 'find-face)
75 `(member ,arg (and (fboundp 'face-list) 75 `(find-face ,arg))
76 (face-list)))) 76 (;;(and (fboundp 'face-list)
77 (t 77 ;; (face-list))
78 `(boundp ,arg)))) 78 (fboundp 'face-list)
79 (defmacro cperl-make-face (arg descr) ; Takes unquoted arg 79 `(member ,arg (and (fboundp 'face-list)
80 (cond ((fboundp 'make-face) 80 (face-list))))
81 `(make-face (quote ,arg))) 81 (t
82 (t 82 `(boundp ,arg))))
83 `(defconst ,arg (quote ,arg) ,descr)))) 83 (defmacro cperl-make-face (arg descr) ; Takes unquoted arg
84 (defmacro cperl-force-face (arg descr) ; Takes unquoted arg 84 (cond ((fboundp 'make-face)
85 `(make-face (quote ,arg)))
86 (t
87 `(defconst ,arg (quote ,arg) ,descr))))
88 (defmacro cperl-force-face (arg descr) ; Takes unquoted arg
89 `(progn
90 (or (cperl-is-face (quote ,arg))
91 (cperl-make-face ,arg ,descr))
92 (or (boundp (quote ,arg)) ; We use unquoted variants too
93 (defconst ,arg (quote ,arg) ,descr))))
94 (if cperl-xemacs-p
95 (defmacro cperl-etags-snarf-tag (file line)
85 `(progn 96 `(progn
86 (or (cperl-is-face (quote ,arg)) 97 (beginning-of-line 2)
87 (cperl-make-face ,arg ,descr)) 98 (list ,file ,line)))
88 (or (boundp (quote ,arg)) ; We use unquoted variants too 99 (defmacro cperl-etags-snarf-tag (file line)
89 (defconst ,arg (quote ,arg) ,descr)))) 100 `(etags-snarf-tag)))
90 (if cperl-xemacs-p 101 (if cperl-xemacs-p
91 (defmacro cperl-etags-snarf-tag (file line) 102 (defmacro cperl-etags-goto-tag-location (elt)
92 `(progn 103 ;;(progn
93 (beginning-of-line 2) 104 ;; (switch-to-buffer (get-file-buffer (elt (, elt) 0)))
94 (list ,file ,line))) 105 ;; (set-buffer (get-file-buffer (elt (, elt) 0)))
95 (defmacro cperl-etags-snarf-tag (file line) 106 ;; Probably will not work due to some save-excursion???
96 `(etags-snarf-tag))) 107 ;; Or save-file-position?
97 (if cperl-xemacs-p 108 ;; (message "Did I get to line %s?" (elt (, elt) 1))
98 (defmacro cperl-etags-goto-tag-location (elt) 109 `(goto-line (string-to-int (elt ,elt 1))))
99 ;;(progn 110 ;;)
100 ;; (switch-to-buffer (get-file-buffer (elt (, elt) 0))) 111 (defmacro cperl-etags-goto-tag-location (elt)
101 ;; (set-buffer (get-file-buffer (elt (, elt) 0))) 112 `(etags-goto-tag-location ,elt)))
102 ;; Probably will not work due to some save-excursion??? 113 (autoload 'tmm-prompt "tmm"))
103 ;; Or save-file-position?
104 ;; (message "Did I get to line %s?" (elt (, elt) 1))
105 `(goto-line (string-to-int (elt ,elt 1))))
106 ;;)
107 (defmacro cperl-etags-goto-tag-location (elt)
108 `(etags-goto-tag-location ,elt)))))
109 114
110(defun cperl-choose-color (&rest list) 115(defun cperl-choose-color (&rest list)
111 (let (answer) 116 (let (answer)
@@ -343,24 +348,24 @@ Can be overwritten by `cperl-hairy' to be 5 sec if nil."
343 :group 'cperl-affected-by-hairy) 348 :group 'cperl-affected-by-hairy)
344 349
345(defcustom cperl-pod-face 'font-lock-comment-face 350(defcustom cperl-pod-face 'font-lock-comment-face
346 "*The result of evaluation of this expression is used for pod highlighting." 351 "*Face for pod highlighting."
347 :type 'face 352 :type 'face
348 :group 'cperl-faces) 353 :group 'cperl-faces)
349 354
350(defcustom cperl-pod-head-face 'font-lock-variable-name-face 355(defcustom cperl-pod-head-face 'font-lock-variable-name-face
351 "*The result of evaluation of this expression is used for pod highlighting. 356 "*Face for pod highlighting.
352Font for POD headers." 357Font for POD headers."
353 :type 'face 358 :type 'face
354 :group 'cperl-faces) 359 :group 'cperl-faces)
355 360
356(defcustom cperl-here-face 'font-lock-string-face 361(defcustom cperl-here-face 'font-lock-string-face
357 "*The result of evaluation of this expression is used for here-docs highlighting." 362 "*Face for here-docs highlighting."
358 :type 'face 363 :type 'face
359 :group 'cperl-faces) 364 :group 'cperl-faces)
360 365
361(defcustom cperl-invalid-face ''underline ; later evaluated by `font-lock' 366(defcustom cperl-invalid-face 'underline
362 "*The result of evaluation of this expression highlights trailing whitespace." 367 "*Face for highlighting trailing whitespace."
363 :type 'sexp 368 :type 'face
364 :group 'cperl-faces) 369 :group 'cperl-faces)
365 370
366(defcustom cperl-pod-here-fontify '(featurep 'font-lock) 371(defcustom cperl-pod-here-fontify '(featurep 'font-lock)
@@ -964,38 +969,34 @@ the faces: please specify bold, italic, underline, shadow and box.)
964;;;(and (boundp 'interpreter-mode-alist) 969;;;(and (boundp 'interpreter-mode-alist)
965;;; (setq interpreter-mode-alist (append interpreter-mode-alist 970;;; (setq interpreter-mode-alist (append interpreter-mode-alist
966;;; '(("miniperl" . perl-mode)))))) 971;;; '(("miniperl" . perl-mode))))))
967(if (fboundp 'eval-when-compile) 972(eval-when-compile
968 (eval-when-compile 973 (condition-case nil
969 (condition-case nil 974 (require 'imenu)
970 (require 'imenu) 975 (error nil))
971 (error nil)) 976 (condition-case nil
972 (condition-case nil 977 (require 'easymenu)
973 (require 'easymenu) 978 (error nil))
974 (error nil)) 979 (condition-case nil
975 (condition-case nil 980 (require 'etags)
976 (require 'etags) 981 (error nil))
977 (error nil)) 982 (condition-case nil
978 (condition-case nil 983 (require 'timer)
979 (require 'timer) 984 (error nil))
980 (error nil)) 985 (condition-case nil
981 (condition-case nil 986 (require 'man)
982 (require 'man) 987 (error nil))
983 (error nil)) 988 (condition-case nil
984 (condition-case nil 989 (require 'info)
985 (require 'info) 990 (error nil))
986 (error nil)) 991 (if (fboundp 'ps-extend-face-list)
987 (if (fboundp 'ps-extend-face-list) 992 (defmacro cperl-ps-extend-face-list (arg)
988 (defmacro cperl-ps-extend-face-list (arg) 993 `(ps-extend-face-list ,arg))
989 `(ps-extend-face-list ,arg)) 994 (defmacro cperl-ps-extend-face-list (arg)
990 (defmacro cperl-ps-extend-face-list (arg) 995 `(error "This version of Emacs has no `ps-extend-face-list'.")))
991 `(error "This version of Emacs has no `ps-extend-face-list'."))) 996 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs,
992 ;; Calling `cperl-enable-font-lock' below doesn't compile on XEmacs, 997 ;; macros instead of defsubsts don't work on Emacs, so we do the
993 ;; macros instead of defsubsts don't work on Emacs, so we do the 998 ;; expansion manually. Any other suggestions?
994 ;; expansion manually. Any other suggestions? 999 (require 'cl))
995 (if (or (string-match "XEmacs\\|Lucid" emacs-version)
996 window-system)
997 (require 'font-lock))
998 (require 'cl)))
999 1000
1000(defvar cperl-mode-abbrev-table nil 1001(defvar cperl-mode-abbrev-table nil
1001 "Abbrev table in use in Cperl-mode buffers.") 1002 "Abbrev table in use in Cperl-mode buffers.")
@@ -1232,10 +1233,6 @@ The expansion is entirely correct because it uses the C preprocessor."
1232(defvar cperl-faces-init nil) 1233(defvar cperl-faces-init nil)
1233;; Fix for msb.el 1234;; Fix for msb.el
1234(defvar cperl-msb-fixed nil) 1235(defvar cperl-msb-fixed nil)
1235(defvar font-lock-syntactic-keywords)
1236(defvar perl-font-lock-keywords)
1237(defvar perl-font-lock-keywords-1)
1238(defvar perl-font-lock-keywords-2)
1239;;;###autoload 1236;;;###autoload
1240(defun cperl-mode () 1237(defun cperl-mode ()
1241 "Major mode for editing Perl code. 1238 "Major mode for editing Perl code.
@@ -1470,7 +1467,7 @@ or as help on variables `cperl-tips', `cperl-problems',
1470 ;;(setq auto-fill-function 'cperl-do-auto-fill) ; Need to switch on and off! 1467 ;;(setq auto-fill-function 'cperl-do-auto-fill) ; Need to switch on and off!
1471 (make-local-variable 'imenu-create-index-function) 1468 (make-local-variable 'imenu-create-index-function)
1472 (setq imenu-create-index-function 1469 (setq imenu-create-index-function
1473 (function imenu-example--create-perl-index)) 1470 (function cperl-imenu--create-perl-index))
1474 (make-local-variable 'imenu-sort-function) 1471 (make-local-variable 'imenu-sort-function)
1475 (setq imenu-sort-function nil) 1472 (setq imenu-sort-function nil)
1476 (make-local-variable 'vc-header-alist) 1473 (make-local-variable 'vc-header-alist)
@@ -1512,14 +1509,8 @@ or as help on variables `cperl-tips', `cperl-problems',
1512 '(t (cperl-fontify-syntaxically)) 1509 '(t (cperl-fontify-syntaxically))
1513 '(t))))) 1510 '(t)))))
1514 (make-local-variable 'cperl-old-style) 1511 (make-local-variable 'cperl-old-style)
1515 (or (fboundp 'cperl-old-auto-fill-mode) 1512 (set (make-local-variable 'normal-auto-fill-function)
1516 (progn 1513 #'cperl-old-auto-fill-mode)
1517 (fset 'cperl-old-auto-fill-mode (symbol-function 'auto-fill-mode))
1518 (defun auto-fill-mode (&optional arg)
1519 (interactive "P")
1520 (eval '(cperl-old-auto-fill-mode arg)) ; Avoid a warning
1521 (and auto-fill-function (eq major-mode 'perl-mode)
1522 (setq auto-fill-function 'cperl-do-auto-fill)))))
1523 (if (cperl-enable-font-lock) 1514 (if (cperl-enable-font-lock)
1524 (if (cperl-val 'cperl-font-lock) 1515 (if (cperl-val 'cperl-font-lock)
1525 (progn (or cperl-faces-init (cperl-init-faces)) 1516 (progn (or cperl-faces-init (cperl-init-faces))
@@ -1540,7 +1531,6 @@ or as help on variables `cperl-tips', `cperl-problems',
1540 (cperl-find-pods-heres))))) 1531 (cperl-find-pods-heres)))))
1541 1532
1542;; Fix for perldb - make default reasonable 1533;; Fix for perldb - make default reasonable
1543(defvar gud-perldb-history)
1544(defun cperl-db () 1534(defun cperl-db ()
1545 (interactive) 1535 (interactive)
1546 (require 'gud) 1536 (require 'gud)
@@ -1555,7 +1545,6 @@ or as help on variables `cperl-tips', `cperl-problems',
1555 nil nil 1545 nil nil
1556 '(gud-perldb-history . 1)))) 1546 '(gud-perldb-history . 1))))
1557 1547
1558(defvar msb-menu-cond)
1559(defun cperl-msb-fix () 1548(defun cperl-msb-fix ()
1560 ;; Adds perl files to msb menu, supposes that msb is already loaded 1549 ;; Adds perl files to msb menu, supposes that msb is already loaded
1561 (setq cperl-msb-fixed t) 1550 (setq cperl-msb-fixed t)
@@ -3004,9 +2993,6 @@ Returns true if comment is found."
3004 ;; go-forward: has 2 args, and the second part is empth 2993 ;; go-forward: has 2 args, and the second part is empth
3005 (list i i2 ender starter go-forward))) 2994 (list i i2 ender starter go-forward)))
3006 2995
3007(defvar font-lock-string-face)
3008;;(defvar font-lock-reference-face)
3009(defvar font-lock-constant-face)
3010(defsubst cperl-postpone-fontification (b e type val &optional now) 2996(defsubst cperl-postpone-fontification (b e type val &optional now)
3011 ;; Do after syntactic fontification? 2997 ;; Do after syntactic fontification?
3012 (if cperl-syntaxify-by-font-lock 2998 (if cperl-syntaxify-by-font-lock
@@ -3701,9 +3687,6 @@ CHARS is a string that contains good characters to have before us (however,
3701 "\\(map\\|grep\\|printf?\\|system\\|exec\\|tr\\|s\\)\\>"))))))) 3687 "\\(map\\|grep\\|printf?\\|system\\|exec\\|tr\\|s\\)\\>")))))))
3702 3688
3703 3689
3704(defvar innerloop-done nil)
3705(defvar last-depth nil)
3706
3707(defun cperl-indent-exp () 3690(defun cperl-indent-exp ()
3708 "Simple variant of indentation of continued-sexp. 3691 "Simple variant of indentation of continued-sexp.
3709 3692
@@ -4116,7 +4099,7 @@ indentation and initial hashes. Behaves usually outside of comment."
4116 ;; Previous space could have gone: 4099 ;; Previous space could have gone:
4117 (or (memq (preceding-char) '(?\ ?\t)) (insert " ")))))) 4100 (or (memq (preceding-char) '(?\ ?\t)) (insert " "))))))
4118 4101
4119(defvar imenu-example--function-name-regexp-perl 4102(defvar cperl-imenu--function-name-regexp-perl
4120 (concat 4103 (concat
4121 "^\\(" 4104 "^\\("
4122 "[ \t]*\\(sub\\|package\\)[ \t\n]+\\([a-zA-Z_0-9:']+\\)[ \t]*\\(([^()]*)[ \t]*\\)?" 4105 "[ \t]*\\(sub\\|package\\)[ \t\n]+\\([a-zA-Z_0-9:']+\\)[ \t]*\\(([^()]*)[ \t]*\\)?"
@@ -4144,8 +4127,7 @@ indentation and initial hashes. Behaves usually outside of comment."
4144 (if isback (cdr lst) lst)) 4127 (if isback (cdr lst) lst))
4145 lst))) 4128 lst)))
4146 4129
4147(defun imenu-example--create-perl-index (&optional regexp) 4130(defun cperl-imenu--create-perl-index (&optional regexp)
4148 (require 'cl)
4149 (require 'imenu) ; May be called from TAGS creator 4131 (require 'imenu) ; May be called from TAGS creator
4150 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '()) 4132 (let ((index-alist '()) (index-pack-alist '()) (index-pod-alist '())
4151 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function)) 4133 (index-unsorted-alist '()) (i-s-f (default-value 'imenu-sort-function))
@@ -4159,7 +4141,7 @@ indentation and initial hashes. Behaves usually outside of comment."
4159 ;; Search for the function 4141 ;; Search for the function
4160 (progn ;;save-match-data 4142 (progn ;;save-match-data
4161 (while (re-search-forward 4143 (while (re-search-forward
4162 (or regexp imenu-example--function-name-regexp-perl) 4144 (or regexp cperl-imenu--function-name-regexp-perl)
4163 nil t) 4145 nil t)
4164 (or noninteractive 4146 (or noninteractive
4165 (imenu-progress-message prev-pos)) 4147 (imenu-progress-message prev-pos))
@@ -4319,6 +4301,13 @@ indentation and initial hashes. Behaves usually outside of comment."
4319 "ps-print" 4301 "ps-print"
4320 '(or cperl-faces-init (cperl-init-faces)))))) 4302 '(or cperl-faces-init (cperl-init-faces))))))
4321 4303
4304(defvar perl-font-lock-keywords-1 nil
4305 "Additional expressions to highlight in Perl mode. Minimal set.")
4306(defvar perl-font-lock-keywords nil
4307 "Additional expressions to highlight in Perl mode. Default set.")
4308(defvar perl-font-lock-keywords-2 nil
4309 "Additional expressions to highlight in Perl mode. Maximal set")
4310
4322(defun cperl-load-font-lock-keywords () 4311(defun cperl-load-font-lock-keywords ()
4323 (or cperl-faces-init (cperl-init-faces)) 4312 (or cperl-faces-init (cperl-init-faces))
4324 perl-font-lock-keywords) 4313 perl-font-lock-keywords)
@@ -4331,15 +4320,6 @@ indentation and initial hashes. Behaves usually outside of comment."
4331 (or cperl-faces-init (cperl-init-faces)) 4320 (or cperl-faces-init (cperl-init-faces))
4332 perl-font-lock-keywords-2) 4321 perl-font-lock-keywords-2)
4333 4322
4334(defvar perl-font-lock-keywords-1 nil
4335 "Additional expressions to highlight in Perl mode. Minimal set.")
4336(defvar perl-font-lock-keywords nil
4337 "Additional expressions to highlight in Perl mode. Default set.")
4338(defvar perl-font-lock-keywords-2 nil
4339 "Additional expressions to highlight in Perl mode. Maximal set")
4340
4341(defvar font-lock-background-mode)
4342(defvar font-lock-display-type)
4343(defun cperl-init-faces-weak () 4323(defun cperl-init-faces-weak ()
4344 ;; Allow `cperl-find-pods-heres' to run. 4324 ;; Allow `cperl-find-pods-heres' to run.
4345 (or (boundp 'font-lock-constant-face) 4325 (or (boundp 'font-lock-constant-face)
@@ -5297,7 +5277,6 @@ See `cperl-lazy-help-time' too."
5297 (set 'parse-sexp-lookup-properties t)))) 5277 (set 'parse-sexp-lookup-properties t))))
5298 5278
5299(defun cperl-xsub-scan () 5279(defun cperl-xsub-scan ()
5300 (require 'cl)
5301 (require 'imenu) 5280 (require 'imenu)
5302 (let ((index-alist '()) 5281 (let ((index-alist '())
5303 (prev-pos 0) index index1 name package prefix) 5282 (prev-pos 0) index index1 name package prefix)
@@ -5359,7 +5338,7 @@ See `cperl-lazy-help-time' too."
5359 (error (message "While scanning for syntax: %s" err)))) 5338 (error (message "While scanning for syntax: %s" err))))
5360 (if xs 5339 (if xs
5361 (setq lst (cperl-xsub-scan)) 5340 (setq lst (cperl-xsub-scan))
5362 (setq ind (imenu-example--create-perl-index)) 5341 (setq ind (cperl-imenu--create-perl-index))
5363 (setq lst (cdr (assoc "+Unsorted List+..." ind)))) 5342 (setq lst (cdr (assoc "+Unsorted List+..." ind))))
5364 (setq lst 5343 (setq lst
5365 (mapcar 5344 (mapcar