X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2b0c7330457b8ca42375c92ada7dc7cefb0fa9fb..7cef3569a3d872ea5be07a529b68910bf1d8b790:/lisp/progmodes/cperl-mode.el diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index f6d497569b..e1430b67e9 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1,6 +1,6 @@ ;;; cperl-mode.el --- Perl code editing commands for Emacs -;; Copyright (C) 1985-1987, 1991-2011 Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1991-2012 Free Software Foundation, Inc. ;; Author: Ilya Zakharevich ;; Bob Olson @@ -613,7 +613,7 @@ One should tune up `cperl-close-paren-offset' as well." (defcustom cperl-syntaxify-by-font-lock (and cperl-can-font-lock (boundp 'parse-sexp-lookup-properties)) - "*Non-nil means that CPerl uses `font-lock's routines for syntaxification." + "*Non-nil means that CPerl uses the `font-lock' routines for syntaxification." :type '(choice (const message) boolean) :group 'cperl-speed) @@ -839,7 +839,7 @@ voice); b) Can lineup vertically \"middles\" of rows, like `=' in a = b; cc = d; - c) Can insert spaces where this impoves readability (in one + c) Can insert spaces where this improves readability (in one interactive sweep over the buffer); d) Has support for imenu, including: 1) Separate unordered list of \"interesting places\"; @@ -902,7 +902,7 @@ the settings present before the switch. 9) When doing indentation of control constructs, may correct line-breaks/spacing between elements of the construct. -10) Uses a linear-time algorith for indentation of regions (on Emaxen with +10) Uses a linear-time algorithm for indentation of regions (on Emaxen with capable syntax engines). 11) Syntax-highlight, indentation, sexp-recognition inside regular expressions. @@ -927,7 +927,7 @@ syntax-parsing routines, and marks them up so that either A1) CPerl may work around these deficiencies (for big chunks, mostly PODs and HERE-documents), or - A2) On capable Emaxen CPerl will use improved syntax-handlings + A2) On capable Emaxen CPerl will use improved syntax-handling which reads mark-up hints directly. The scan in case A2 is much more comprehensive, thus may be slower. @@ -958,7 +958,7 @@ B) Speed of editing operations. `cperl-array-face' Array names `cperl-hash-face' Hash names `font-lock-comment-face' Comments, PODs and whatever is considered - syntaxically to be not code + syntactically to be not code `font-lock-constant-face' HERE-doc delimiters, labels, delimiters of 2-arg operators s/y/tr/ or of RExen, `font-lock-warning-face' Special-cased m// and s//foo/, @@ -970,7 +970,7 @@ B) Speed of editing operations. `cperl-nonoverridable-face' Non-overridable keywords, modifiers of RExen `font-lock-string-face' Strings, qw() constructs, RExen, POD sections, literal parts and the terminator of formats - and whatever is syntaxically considered + and whatever is syntactically considered as string literals `font-lock-type-face' Overridable keywords `font-lock-variable-name-face' Variable declarations, indirect array and @@ -1277,7 +1277,7 @@ versions of Emacs." "----" ["Ispell PODs" cperl-pod-spell ;; Better not to update syntaxification here: - ;; debugging syntaxificatio can be broken by this??? + ;; debugging syntaxification can be broken by this??? (or (get-text-property (point-min) 'in-pod) (< (progn @@ -1304,7 +1304,7 @@ versions of Emacs." (get-text-property (point) 'syntax-type)) '(here-doc pod))] "----" - ["CPerl pretty print (exprmntl)" cperl-ps-print + ["CPerl pretty print (experimental)" cperl-ps-print (fboundp 'ps-extend-face-list)] "----" ["Syntaxify region" cperl-find-pods-heres-region @@ -1388,12 +1388,12 @@ The expansion is entirely correct because it uses the C preprocessor." ;;; These two must be unwound, otherwise take exponential time (defconst cperl-maybe-white-and-comment-rex "[ \t\n]*\\(#[^\n]*\n[ \t\n]*\\)*" -"Regular expression to match optional whitespace with interpspersed comments. +"Regular expression to match optional whitespace with interspersed comments. Should contain exactly one group.") ;;; This one is tricky to unwind; still very inefficient... (defconst cperl-white-and-comment-rex "\\([ \t\n]\\|#[^\n]*\n\\)+" -"Regular expression to match whitespace with interpspersed comments. +"Regular expression to match whitespace with interspersed comments. Should contain exactly one group.") @@ -1512,7 +1512,7 @@ the last)." (defvar cperl-font-locking nil) ;; NB as it stands the code in cperl-mode assumes this only has one -;; element. If Xemacs 19 support were dropped, this could all be simplified. +;; element. If XEmacs 19 support were dropped, this could all be simplified. (defvar cperl-compilation-error-regexp-alist ;; This look like a paranoiac regexp: could anybody find a better one? (which WORKS). '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\., \n]" @@ -1522,7 +1522,7 @@ the last)." (defvar compilation-error-regexp-alist) ;;;###autoload -(defun cperl-mode () +(define-derived-mode cperl-mode prog-mode "CPerl" "Major mode for editing Perl code. Expression and list commands understand all C brackets. Tab indents for Perl code. @@ -1537,8 +1537,8 @@ default.) You can always quote (with \\[quoted-insert]) the left since most the time you mean \"less\". CPerl mode tries to guess whether you want to type pair <>, and inserts is if it appropriate. You can set `cperl-electric-parens-string' to the string that -contains the parenths from the above list you want to be electrical. -Electricity of parenths is controlled by `cperl-electric-parens'. +contains the parens from the above list you want to be electrical. +Electricity of parens is controlled by `cperl-electric-parens'. You may also set `cperl-electric-parens-mark' to have electric parens look for active mark and \"embrace\" a region if possible.' @@ -1695,9 +1695,6 @@ with no args. DO NOT FORGET to read micro-docs (available from `Perl' menu) or as help on variables `cperl-tips', `cperl-problems', `cperl-praise', `cperl-speed'." - (interactive) - (kill-all-local-variables) - (use-local-map cperl-mode-map) (if (cperl-val 'cperl-electric-linefeed) (progn (local-set-key "\C-J" 'cperl-linefeed) @@ -1710,8 +1707,6 @@ or as help on variables `cperl-tips', `cperl-problems', (cperl-define-key "\C-hf" 'cperl-info-on-current-command [(control h) f]) (cperl-define-key "\C-c\C-hf" 'cperl-info-on-command [(control c) (control h) f]))) - (setq major-mode cperl-use-major-mode) - (setq mode-name "CPerl") (let ((prev-a-c abbrevs-changed)) (define-abbrev-table 'cperl-mode-abbrev-table '( ("if" "if" cperl-electric-keyword 0) @@ -1816,7 +1811,7 @@ or as help on variables `cperl-tips', `cperl-problems', (funcall f)) (make-local-variable 'compilation-error-regexp-alist) (push 'cperl compilation-error-regexp-alist))) - ((boundp 'compilation-error-regexp-alist);; xmeacs 19.x + ((boundp 'compilation-error-regexp-alist);; xemacs 19.x (make-local-variable 'compilation-error-regexp-alist) (set 'compilation-error-regexp-alist (append cperl-compilation-error-regexp-alist @@ -1843,7 +1838,13 @@ or as help on variables `cperl-tips', `cperl-problems', (set (make-local-variable 'cperl-syntax-done-to) nil) (set (make-local-variable 'syntax-propertize-function) (lambda (start end) - (goto-char start) (cperl-fontify-syntaxically end)))) + (goto-char start) + ;; Even if cperl-fontify-syntaxically has already gone + ;; beyond `start', syntax-propertize has just removed + ;; syntax-table properties between start and end, so we have + ;; to re-apply them. + (setq cperl-syntax-done-to start) + (cperl-fontify-syntaxically end)))) (make-local-variable 'parse-sexp-lookup-properties) ;; Do not introduce variable if not needed, we check it! (set 'parse-sexp-lookup-properties t) @@ -2327,8 +2328,7 @@ to nil." nil t)))) ; Only one (progn (forward-word 1) - (setq name (file-name-sans-extension - (file-name-nondirectory (buffer-file-name))) + (setq name (file-name-base) p (point)) (insert " NAME\n\n" name " - \n\n=head1 SYNOPSIS\n\n\n\n" @@ -2806,7 +2806,7 @@ Will not look before LIM." (skip-chars-forward " \t") (if (memq (char-after (point)) (append "#\n" nil)) - nil ; Can't use intentation of this line... + nil ; Can't use indentation of this line... (point))) (skip-chars-forward " \t") (point))) @@ -3503,7 +3503,8 @@ Works before syntax recognition is done." (if end ;; Do the same for end, going small steps (save-excursion - (while (and end (get-text-property end 'syntax-type)) + (while (and end (< end (point-max)) + (get-text-property end 'syntax-type)) (setq pos end end (next-single-property-change end 'syntax-type nil (point-max))) (if end (progn (goto-char end) @@ -3522,7 +3523,7 @@ Works before syntax recognition is done." (defvar font-lock-warning-face) (defun cperl-find-sub-attrs (&optional st-l b-fname e-fname pos) - "Syntaxically mark (and fontify) attributes of a subroutine. + "Syntactically mark (and fontify) attributes of a subroutine. Should be called with the point before leading colon of an attribute." ;; Works *before* syntax recognition is done (or st-l (setq st-l (list nil))) ; Avoid overwriting '() @@ -4545,7 +4546,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face', (forward-char 2)) (and (eq (following-char) ?\] ) (forward-char 1))) - (setq REx-subgr-end qtag) ;EndOf smart-highlighed + (setq REx-subgr-end qtag) ;End smart-highlighted ;; Apparently, I can't put \] into a charclass ;; in m]]: m][\\\]\]] produces [\\]] ;;; POSIX? [:word:] [:^word:] only inside [] @@ -4999,7 +5000,7 @@ conditional/loop constructs." (setq top (point)) ;; Plan A: if line has an unfinished paren-group, go to end-of-group (while (= -1 (nth 0 (parse-partial-sexp (point) tmp-end -1))) - (setq top (point))) ; Get the outermost parenths in line + (setq top (point))) ; Get the outermost parens in line (goto-char top) (while (< (point) tmp-end) (parse-partial-sexp (point) tmp-end nil t) ; To start-sexp or eol @@ -5798,7 +5799,7 @@ indentation and initial hashes. Behaves usually outside of comment." ;; "\\|") '("-[rwxoRWXOezsfdlpSbctugkTBMAC]\\>\\([ \t]+_\\>\\)?" 0 font-lock-function-name-face keep) ; Not very good, triggers at "[a-z]" - ;; This highlights declarations and definitions differenty. + ;; This highlights declarations and definitions differently. ;; We do not try to highlight in the case of attributes: ;; it is already done by `cperl-find-pods-heres' (list (concat "\\