diff options
| author | Michael R. Mauger | 2017-07-24 22:15:04 -0400 |
|---|---|---|
| committer | Michael R. Mauger | 2017-07-24 22:15:04 -0400 |
| commit | df1a71272e5cdd10b511e2ffd702ca50ddd8a773 (patch) | |
| tree | 9b9ac725394ee80891e2bff57b6407d0e491e71a /lisp/progmodes | |
| parent | eb27fc4d49e8c914cd0e6a8a2d02159601542141 (diff) | |
| parent | 32daa3cb54523006c88717cbeac87964cd687a1b (diff) | |
| download | emacs-df1a71272e5cdd10b511e2ffd702ca50ddd8a773.tar.gz emacs-df1a71272e5cdd10b511e2ffd702ca50ddd8a773.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 27 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 12 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 21 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 66 | ||||
| -rw-r--r-- | lisp/progmodes/cperl-mode.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/executable.el | 36 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 104 | ||||
| -rw-r--r-- | lisp/progmodes/ld-script.el | 9 | ||||
| -rw-r--r-- | lisp/progmodes/perl-mode.el | 43 | ||||
| -rw-r--r-- | lisp/progmodes/xref.el | 33 |
10 files changed, 213 insertions, 142 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 121ba24f090..dec59c58090 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1843,19 +1843,25 @@ with a brace block." | |||
| 1843 | (unless (eq where 'at-header) | 1843 | (unless (eq where 'at-header) |
| 1844 | (c-backward-to-nth-BOF-{ 1 where) | 1844 | (c-backward-to-nth-BOF-{ 1 where) |
| 1845 | (c-beginning-of-decl-1)) | 1845 | (c-beginning-of-decl-1)) |
| 1846 | (when (looking-at c-typedef-key) | ||
| 1847 | (goto-char (match-end 0)) | ||
| 1848 | (c-forward-syntactic-ws)) | ||
| 1846 | 1849 | ||
| 1847 | ;; Pick out the defun name, according to the type of defun. | 1850 | ;; Pick out the defun name, according to the type of defun. |
| 1848 | (cond | 1851 | (cond |
| 1849 | ;; struct, union, enum, or similar: | 1852 | ;; struct, union, enum, or similar: |
| 1850 | ((and (looking-at c-type-prefix-key) | 1853 | ((looking-at c-type-prefix-key) |
| 1851 | (progn (c-forward-token-2 2) ; over "struct foo " | 1854 | (let ((key-pos (point))) |
| 1852 | (or (eq (char-after) ?\{) | 1855 | (c-forward-token-2 1) ; over "struct ". |
| 1853 | (looking-at c-symbol-key)))) ; "struct foo bar ..." | 1856 | (cond |
| 1854 | (save-match-data (c-forward-token-2)) | 1857 | ((looking-at c-symbol-key) ; "struct foo { ..." |
| 1855 | (when (eq (char-after) ?\{) | 1858 | (buffer-substring-no-properties key-pos (match-end 0))) |
| 1856 | (c-backward-token-2) | 1859 | ((eq (char-after) ?{) ; "struct { ... } foo" |
| 1857 | (looking-at c-symbol-key)) | 1860 | (when (c-go-list-forward) |
| 1858 | (match-string-no-properties 0)) | 1861 | (c-forward-syntactic-ws) |
| 1862 | (when (looking-at c-symbol-key) ; a bit bogus - there might | ||
| 1863 | ; be several identifiers. | ||
| 1864 | (match-string-no-properties 0))))))) | ||
| 1859 | 1865 | ||
| 1860 | ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs! | 1866 | ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs! |
| 1861 | ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory | 1867 | ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory |
| @@ -1900,7 +1906,8 @@ with a brace block." | |||
| 1900 | (c-backward-syntactic-ws)) | 1906 | (c-backward-syntactic-ws)) |
| 1901 | (setq name-end (point)) | 1907 | (setq name-end (point)) |
| 1902 | (c-back-over-compound-identifier) | 1908 | (c-back-over-compound-identifier) |
| 1903 | (buffer-substring-no-properties (point) name-end))))))))) | 1909 | (and (looking-at c-symbol-start) |
| 1910 | (buffer-substring-no-properties (point) name-end)))))))))) | ||
| 1904 | 1911 | ||
| 1905 | (defun c-declaration-limits (near) | 1912 | (defun c-declaration-limits (near) |
| 1906 | ;; Return a cons of the beginning and end positions of the current | 1913 | ;; Return a cons of the beginning and end positions of the current |
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index eb7bde0f767..ab910ab7dec 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -417,6 +417,17 @@ to it is returned. This function does not modify the point or the mark." | |||
| 417 | ;; Emacs. | 417 | ;; Emacs. |
| 418 | `(setq mark-active ,activate))) | 418 | `(setq mark-active ,activate))) |
| 419 | 419 | ||
| 420 | (defmacro c-set-keymap-parent (map parent) | ||
| 421 | (cond | ||
| 422 | ;; XEmacs | ||
| 423 | ((cc-bytecomp-fboundp 'set-keymap-parents) | ||
| 424 | `(set-keymap-parents ,map ,parent)) | ||
| 425 | ;; Emacs | ||
| 426 | ((cc-bytecomp-fboundp 'set-keymap-parent) | ||
| 427 | `(set-keymap-parent ,map ,parent)) | ||
| 428 | ;; incompatible | ||
| 429 | (t (error "CC Mode is incompatible with this version of Emacs")))) | ||
| 430 | |||
| 420 | (defmacro c-delete-and-extract-region (start end) | 431 | (defmacro c-delete-and-extract-region (start end) |
| 421 | "Delete the text between START and END and return it." | 432 | "Delete the text between START and END and return it." |
| 422 | (if (cc-bytecomp-fboundp 'delete-and-extract-region) | 433 | (if (cc-bytecomp-fboundp 'delete-and-extract-region) |
| @@ -1266,6 +1277,7 @@ with value CHAR in the region [FROM to)." | |||
| 1266 | (def-edebug-spec cc-eval-when-compile (&rest def-form)) | 1277 | (def-edebug-spec cc-eval-when-compile (&rest def-form)) |
| 1267 | (def-edebug-spec c-point t) | 1278 | (def-edebug-spec c-point t) |
| 1268 | (def-edebug-spec c-set-region-active t) | 1279 | (def-edebug-spec c-set-region-active t) |
| 1280 | (def-edebug-spec c-set-keymap-parent t) | ||
| 1269 | (def-edebug-spec c-safe t) | 1281 | (def-edebug-spec c-safe t) |
| 1270 | (def-edebug-spec c-save-buffer-state let*) | 1282 | (def-edebug-spec c-save-buffer-state let*) |
| 1271 | (def-edebug-spec c-tentative-buffer-changes t) | 1283 | (def-edebug-spec c-tentative-buffer-changes t) |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index e880bd39321..59dc96af030 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -6089,7 +6089,8 @@ comment at the start of cc-engine.el for more info." | |||
| 6089 | 6089 | ||
| 6090 | (defsubst c-clear-found-types () | 6090 | (defsubst c-clear-found-types () |
| 6091 | ;; Clears `c-found-types'. | 6091 | ;; Clears `c-found-types'. |
| 6092 | (setq c-found-types (make-vector 53 0))) | 6092 | (setq c-found-types |
| 6093 | (make-hash-table :test #'equal :weakness nil))) | ||
| 6093 | 6094 | ||
| 6094 | (defun c-add-type (from to) | 6095 | (defun c-add-type (from to) |
| 6095 | ;; Add the given region as a type in `c-found-types'. If the region | 6096 | ;; Add the given region as a type in `c-found-types'. If the region |
| @@ -6103,29 +6104,27 @@ comment at the start of cc-engine.el for more info." | |||
| 6103 | ;; | 6104 | ;; |
| 6104 | ;; This function might do hidden buffer changes. | 6105 | ;; This function might do hidden buffer changes. |
| 6105 | (let ((type (c-syntactic-content from to c-recognize-<>-arglists))) | 6106 | (let ((type (c-syntactic-content from to c-recognize-<>-arglists))) |
| 6106 | (unless (intern-soft type c-found-types) | 6107 | (unless (gethash type c-found-types) |
| 6107 | (unintern (substring type 0 -1) c-found-types) | 6108 | (remhash (substring type 0 -1) c-found-types) |
| 6108 | (intern type c-found-types)))) | 6109 | (puthash type t c-found-types)))) |
| 6109 | 6110 | ||
| 6110 | (defun c-unfind-type (name) | 6111 | (defun c-unfind-type (name) |
| 6111 | ;; Remove the "NAME" from c-found-types, if present. | 6112 | ;; Remove the "NAME" from c-found-types, if present. |
| 6112 | (unintern name c-found-types)) | 6113 | (remhash name c-found-types)) |
| 6113 | 6114 | ||
| 6114 | (defsubst c-check-type (from to) | 6115 | (defsubst c-check-type (from to) |
| 6115 | ;; Return non-nil if the given region contains a type in | 6116 | ;; Return non-nil if the given region contains a type in |
| 6116 | ;; `c-found-types'. | 6117 | ;; `c-found-types'. |
| 6117 | ;; | 6118 | ;; |
| 6118 | ;; This function might do hidden buffer changes. | 6119 | ;; This function might do hidden buffer changes. |
| 6119 | (intern-soft (c-syntactic-content from to c-recognize-<>-arglists) | 6120 | (gethash (c-syntactic-content from to c-recognize-<>-arglists) c-found-types)) |
| 6120 | c-found-types)) | ||
| 6121 | 6121 | ||
| 6122 | (defun c-list-found-types () | 6122 | (defun c-list-found-types () |
| 6123 | ;; Return all the types in `c-found-types' as a sorted list of | 6123 | ;; Return all the types in `c-found-types' as a sorted list of |
| 6124 | ;; strings. | 6124 | ;; strings. |
| 6125 | (let (type-list) | 6125 | (let (type-list) |
| 6126 | (mapatoms (lambda (type) | 6126 | (maphash (lambda (type _) |
| 6127 | (setq type-list (cons (symbol-name type) | 6127 | (setq type-list (cons type type-list))) |
| 6128 | type-list))) | ||
| 6129 | c-found-types) | 6128 | c-found-types) |
| 6130 | (sort type-list 'string-lessp))) | 6129 | (sort type-list 'string-lessp))) |
| 6131 | 6130 | ||
| @@ -7059,6 +7058,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7059 | ;; This function might do hidden buffer changes. | 7058 | ;; This function might do hidden buffer changes. |
| 7060 | 7059 | ||
| 7061 | (let ((start (point)) | 7060 | (let ((start (point)) |
| 7061 | (old-found-types (copy-hash-table c-found-types)) | ||
| 7062 | ;; If `c-record-type-identifiers' is set then activate | 7062 | ;; If `c-record-type-identifiers' is set then activate |
| 7063 | ;; recording of any found types that constitute an argument in | 7063 | ;; recording of any found types that constitute an argument in |
| 7064 | ;; the arglist. | 7064 | ;; the arglist. |
| @@ -7074,6 +7074,7 @@ comment at the start of cc-engine.el for more info." | |||
| 7074 | (nconc c-record-found-types c-record-type-identifiers))) | 7074 | (nconc c-record-found-types c-record-type-identifiers))) |
| 7075 | t) | 7075 | t) |
| 7076 | 7076 | ||
| 7077 | (setq c-found-types old-found-types) | ||
| 7077 | (goto-char start) | 7078 | (goto-char start) |
| 7078 | nil))) | 7079 | nil))) |
| 7079 | 7080 | ||
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 9b89681c3bf..bf0439ffe8a 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -225,18 +225,7 @@ control). See \"cc-mode.el\" for more info." | |||
| 225 | 225 | ||
| 226 | (defun c-make-inherited-keymap () | 226 | (defun c-make-inherited-keymap () |
| 227 | (let ((map (make-sparse-keymap))) | 227 | (let ((map (make-sparse-keymap))) |
| 228 | ;; Necessary to use `cc-bytecomp-fboundp' below since this | 228 | (c-set-keymap-parent map c-mode-base-map) |
| 229 | ;; function is called from top-level forms that are evaluated | ||
| 230 | ;; while cc-bytecomp is active when one does M-x eval-buffer. | ||
| 231 | (cond | ||
| 232 | ;; Emacs | ||
| 233 | ((cc-bytecomp-fboundp 'set-keymap-parent) | ||
| 234 | (set-keymap-parent map c-mode-base-map)) | ||
| 235 | ;; XEmacs | ||
| 236 | ((fboundp 'set-keymap-parents) | ||
| 237 | (set-keymap-parents map c-mode-base-map)) | ||
| 238 | ;; incompatible | ||
| 239 | (t (error "CC Mode is incompatible with this version of Emacs"))) | ||
| 240 | map)) | 229 | map)) |
| 241 | 230 | ||
| 242 | (defun c-define-abbrev-table (name defs &optional doc) | 231 | (defun c-define-abbrev-table (name defs &optional doc) |
| @@ -276,6 +265,8 @@ control). See \"cc-mode.el\" for more info." | |||
| 276 | nil | 265 | nil |
| 277 | 266 | ||
| 278 | (setq c-mode-base-map (make-sparse-keymap)) | 267 | (setq c-mode-base-map (make-sparse-keymap)) |
| 268 | (when (boundp 'prog-mode-map) | ||
| 269 | (c-set-keymap-parent c-mode-base-map prog-mode-map)) | ||
| 279 | 270 | ||
| 280 | ;; Separate M-BS from C-M-h. The former should remain | 271 | ;; Separate M-BS from C-M-h. The former should remain |
| 281 | ;; backward-kill-word. | 272 | ;; backward-kill-word. |
| @@ -446,27 +437,36 @@ preferably use the `c-mode-menu' language constant directly." | |||
| 446 | t)))) | 437 | t)))) |
| 447 | 438 | ||
| 448 | (defun c-unfind-coalesced-tokens (beg end) | 439 | (defun c-unfind-coalesced-tokens (beg end) |
| 449 | ;; unless the non-empty region (beg end) is entirely WS and there's at | 440 | ;; If removing the region (beg end) would coalesce an identifier ending at |
| 450 | ;; least one character of WS just before or after this region, remove | 441 | ;; beg with an identifier (fragment) beginning at end, or an identifier |
| 451 | ;; the tokens which touch the region from `c-found-types' should they | 442 | ;; fragment ending at beg with an identifier beginning at end, remove the |
| 452 | ;; be present. | 443 | ;; pertinent identifier(s) from `c-found-types'. |
| 453 | (or (c-partial-ws-p beg end) | 444 | (save-excursion |
| 454 | (save-excursion | 445 | (when (< beg end) |
| 455 | (progn | 446 | (goto-char beg) |
| 456 | (goto-char beg) | 447 | (when |
| 457 | (or (eq beg (point-min)) | 448 | (and (not (bobp)) |
| 458 | (c-skip-ws-backward (1- beg)) | 449 | (progn (c-backward-syntactic-ws) (eq (point) beg)) |
| 459 | (/= (point) beg) | 450 | (/= (skip-chars-backward c-symbol-chars (1- (point))) 0) |
| 460 | (= (c-backward-token-2) 1) | 451 | (progn (goto-char beg) (c-forward-syntactic-ws) (<= (point) end)) |
| 461 | (c-unfind-type (buffer-substring-no-properties | 452 | (> (point) beg) |
| 462 | (point) beg))) | 453 | (goto-char end) |
| 463 | (goto-char end) | 454 | (looking-at c-symbol-char-key)) |
| 464 | (or (eq end (point-max)) | 455 | (goto-char beg) |
| 465 | (c-skip-ws-forward (1+ end)) | 456 | (c-simple-skip-symbol-backward) |
| 466 | (/= (point) end) | 457 | (c-unfind-type (buffer-substring-no-properties (point) beg))) |
| 467 | (progn (forward-char) (c-end-of-current-token) nil) | 458 | |
| 468 | (c-unfind-type (buffer-substring-no-properties | 459 | (goto-char end) |
| 469 | end (point)))))))) | 460 | (when |
| 461 | (and (not (eobp)) | ||
| 462 | (progn (c-forward-syntactic-ws) (eq (point) end)) | ||
| 463 | (looking-at c-symbol-char-key) | ||
| 464 | (progn (c-backward-syntactic-ws) (>= (point) beg)) | ||
| 465 | (< (point) end) | ||
| 466 | (/= (skip-chars-backward c-symbol-chars (1- (point))) 0)) | ||
| 467 | (goto-char (1+ end)) | ||
| 468 | (c-end-of-current-token) | ||
| 469 | (c-unfind-type (buffer-substring-no-properties end (point))))))) | ||
| 470 | 470 | ||
| 471 | ;; c-maybe-stale-found-type records a place near the region being | 471 | ;; c-maybe-stale-found-type records a place near the region being |
| 472 | ;; changed where an element of `found-types' might become stale. It | 472 | ;; changed where an element of `found-types' might become stale. It |
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index c0f1aaf39d4..c69eca22413 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el | |||
| @@ -3734,7 +3734,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face', | |||
| 3734 | "\\(\\`\n?\\|^\n\\)=" ; POD | 3734 | "\\(\\`\n?\\|^\n\\)=" ; POD |
| 3735 | "\\|" | 3735 | "\\|" |
| 3736 | ;; One extra () before this: | 3736 | ;; One extra () before this: |
| 3737 | "<<" ; HERE-DOC | 3737 | "<<~?" ; HERE-DOC |
| 3738 | "\\(" ; 1 + 1 | 3738 | "\\(" ; 1 + 1 |
| 3739 | ;; First variant "BLAH" or just ``. | 3739 | ;; First variant "BLAH" or just ``. |
| 3740 | "[ \t]*" ; Yes, whitespace is allowed! | 3740 | "[ \t]*" ; Yes, whitespace is allowed! |
| @@ -4000,7 +4000,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face', | |||
| 4000 | (setq b (point)) | 4000 | (setq b (point)) |
| 4001 | ;; We do not search to max, since we may be called from | 4001 | ;; We do not search to max, since we may be called from |
| 4002 | ;; some hook of fontification, and max is random | 4002 | ;; some hook of fontification, and max is random |
| 4003 | (or (and (re-search-forward (concat "^" qtag "$") | 4003 | (or (and (re-search-forward (concat "^[ \t]*" qtag "$") |
| 4004 | stop-point 'toend) | 4004 | stop-point 'toend) |
| 4005 | ;;;(eq (following-char) ?\n) ; XXXX WHY??? | 4005 | ;;;(eq (following-char) ?\n) ; XXXX WHY??? |
| 4006 | ) | 4006 | ) |
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index da148bd39aa..7c040e74955 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el | |||
| @@ -83,13 +83,21 @@ When this is `function', only ask when called non-interactively." | |||
| 83 | :type 'regexp | 83 | :type 'regexp |
| 84 | :group 'executable) | 84 | :group 'executable) |
| 85 | 85 | ||
| 86 | |||
| 87 | (defcustom executable-prefix "#!" | 86 | (defcustom executable-prefix "#!" |
| 88 | "Interpreter magic number prefix inserted when there was no magic number." | 87 | "Interpreter magic number prefix inserted when there was no magic number. |
| 89 | :version "24.3" ; "#! " -> "#!" | 88 | Use of `executable-prefix-env' is preferable to this option." |
| 89 | :version "26.1" ; deprecated | ||
| 90 | :type 'string | 90 | :type 'string |
| 91 | :group 'executable) | 91 | :group 'executable) |
| 92 | 92 | ||
| 93 | (defcustom executable-prefix-env nil | ||
| 94 | "If non-nil, use \"/usr/bin/env\" in interpreter magic number. | ||
| 95 | If this variable is non-nil, the interpreter magic number inserted | ||
| 96 | by `executable-set-magic' will be \"#!/usr/bin/env INTERPRETER\", | ||
| 97 | otherwise it will be \"#!/path/to/INTERPRETER\"." | ||
| 98 | :version "26.1" | ||
| 99 | :type 'boolean | ||
| 100 | :group 'executable) | ||
| 93 | 101 | ||
| 94 | (defcustom executable-chmod 73 | 102 | (defcustom executable-chmod 73 |
| 95 | "After saving, if the file is not executable, set this mode. | 103 | "After saving, if the file is not executable, set this mode. |
| @@ -199,7 +207,7 @@ command to find the next error. The buffer is also in `comint-mode' and | |||
| 199 | (defun executable-set-magic (interpreter &optional argument | 207 | (defun executable-set-magic (interpreter &optional argument |
| 200 | no-query-flag insert-flag) | 208 | no-query-flag insert-flag) |
| 201 | "Set this buffer's interpreter to INTERPRETER with optional ARGUMENT. | 209 | "Set this buffer's interpreter to INTERPRETER with optional ARGUMENT. |
| 202 | The variables `executable-magicless-file-regexp', `executable-prefix', | 210 | The variables `executable-magicless-file-regexp', `executable-prefix-env', |
| 203 | `executable-insert', `executable-query' and `executable-chmod' control | 211 | `executable-insert', `executable-query' and `executable-chmod' control |
| 204 | when and how magic numbers are inserted or replaced and scripts made | 212 | when and how magic numbers are inserted or replaced and scripts made |
| 205 | executable." | 213 | executable." |
| @@ -220,6 +228,14 @@ executable." | |||
| 220 | (and argument (string< "" argument) " ") | 228 | (and argument (string< "" argument) " ") |
| 221 | argument)) | 229 | argument)) |
| 222 | 230 | ||
| 231 | ;; For backward compatibilty, allow `executable-prefix-env' to be | ||
| 232 | ;; overriden by custom `executable-prefix'. | ||
| 233 | (if (string-match "#!\\([ \t]*/usr/bin/env[ \t]*\\)?$" executable-prefix) | ||
| 234 | (if executable-prefix-env | ||
| 235 | (setq argument (concat "/usr/bin/env " | ||
| 236 | (file-name-nondirectory argument)))) | ||
| 237 | (setq argument (concat (substring executable-prefix 2) argument))) | ||
| 238 | |||
| 223 | (or buffer-read-only | 239 | (or buffer-read-only |
| 224 | (if buffer-file-name | 240 | (if buffer-file-name |
| 225 | (string-match executable-magicless-file-regexp | 241 | (string-match executable-magicless-file-regexp |
| @@ -241,15 +257,13 @@ executable." | |||
| 241 | ;; Make buffer visible before question. | 257 | ;; Make buffer visible before question. |
| 242 | (switch-to-buffer (current-buffer)) | 258 | (switch-to-buffer (current-buffer)) |
| 243 | (y-or-n-p (format-message | 259 | (y-or-n-p (format-message |
| 244 | "Replace magic number by `%s%s'? " | 260 | "Replace magic number by `#!%s'? " |
| 245 | executable-prefix argument)))) | 261 | argument)))) |
| 246 | (progn | 262 | (progn |
| 247 | (replace-match argument t t nil 1) | 263 | (replace-match argument t t nil 1) |
| 248 | (message "Magic number changed to `%s'" | 264 | (message "Magic number changed to `#!%s'" argument)))) |
| 249 | (concat executable-prefix argument))))) | 265 | (insert "#!" argument ?\n) |
| 250 | (insert executable-prefix argument ?\n) | 266 | (message "Magic number changed to `#!%s'" argument)))) |
| 251 | (message "Magic number changed to `%s'" | ||
| 252 | (concat executable-prefix argument))))) | ||
| 253 | interpreter) | 267 | interpreter) |
| 254 | 268 | ||
| 255 | 269 | ||
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index b3d8a51ceeb..2ddaf884bce 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -47,8 +47,8 @@ to avoid computing them again.") | |||
| 47 | (defun grep-apply-setting (symbol value) | 47 | (defun grep-apply-setting (symbol value) |
| 48 | "Set SYMBOL to VALUE, and update `grep-host-defaults-alist'. | 48 | "Set SYMBOL to VALUE, and update `grep-host-defaults-alist'. |
| 49 | SYMBOL should be one of `grep-command', `grep-template', | 49 | SYMBOL should be one of `grep-command', `grep-template', |
| 50 | `grep-use-null-device', `grep-find-command', | 50 | `grep-use-null-device', `grep-find-command' `grep-find-template', |
| 51 | `grep-find-template', `grep-find-use-xargs', or | 51 | `grep-find-use-xargs', `grep-use-null-filename-separator', or |
| 52 | `grep-highlight-matches'." | 52 | `grep-highlight-matches'." |
| 53 | (when grep-host-defaults-alist | 53 | (when grep-host-defaults-alist |
| 54 | (let* ((host-id | 54 | (let* ((host-id |
| @@ -160,6 +160,15 @@ Customize or call the function `grep-apply-setting'." | |||
| 160 | :set 'grep-apply-setting | 160 | :set 'grep-apply-setting |
| 161 | :group 'grep) | 161 | :group 'grep) |
| 162 | 162 | ||
| 163 | (defcustom grep-use-null-filename-separator 'auto-detect | ||
| 164 | "If non-nil, use `grep's `--null' option. | ||
| 165 | This is done to disambiguate file names in `grep's output." | ||
| 166 | :type '(choice (const :tag "Do Not Use `--null'" nil) | ||
| 167 | (const :tag "Use `--null'" t) | ||
| 168 | (other :tag "Not Set" auto-detect)) | ||
| 169 | :set 'grep-apply-setting | ||
| 170 | :group 'grep) | ||
| 171 | |||
| 163 | ;;;###autoload | 172 | ;;;###autoload |
| 164 | (defcustom grep-find-command nil | 173 | (defcustom grep-find-command nil |
| 165 | "The default find command for \\[grep-find]. | 174 | "The default find command for \\[grep-find]. |
| @@ -357,33 +366,53 @@ A grep buffer becomes most recent when you select Grep mode in it. | |||
| 357 | Notice that using \\[next-error] or \\[compile-goto-error] modifies | 366 | Notice that using \\[next-error] or \\[compile-goto-error] modifies |
| 358 | `compilation-last-buffer' rather than `grep-last-buffer'.") | 367 | `compilation-last-buffer' rather than `grep-last-buffer'.") |
| 359 | 368 | ||
| 360 | ;;;###autoload | 369 | (defconst grep--regexp-alist-column |
| 361 | (defconst grep-regexp-alist | 370 | ;; Calculate column positions (col . end-col) of first grep match on a line |
| 362 | '( | 371 | (cons |
| 363 | ;; Use a tight regexp to handle weird file names (with colons | 372 | (lambda () |
| 373 | (when grep-highlight-matches | ||
| 374 | (let* ((beg (match-end 0)) | ||
| 375 | (end (save-excursion (goto-char beg) (line-end-position))) | ||
| 376 | (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face))) | ||
| 377 | (when mbeg | ||
| 378 | (- mbeg beg))))) | ||
| 379 | (lambda () | ||
| 380 | (when grep-highlight-matches | ||
| 381 | (let* ((beg (match-end 0)) | ||
| 382 | (end (save-excursion (goto-char beg) (line-end-position))) | ||
| 383 | (mbeg (text-property-any beg end 'font-lock-face 'grep-match-face)) | ||
| 384 | (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) | ||
| 385 | (when mend | ||
| 386 | (- mend beg))))))) | ||
| 387 | (defconst grep--regexp-alist-bin-matcher | ||
| 388 | '("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) | ||
| 389 | (defconst grep-with-null-regexp-alist | ||
| 390 | `(("^\\([^\0]+\\)\\(\0\\)\\([0-9]+\\):" 1 3 ,grep--regexp-alist-column nil nil | ||
| 391 | (2 '(face unspecified display ":"))) | ||
| 392 | ,grep--regexp-alist-bin-matcher) | ||
| 393 | "Regexp used to match grep hits. | ||
| 394 | See `compilation-error-regexp-alist'.") | ||
| 395 | (defconst grep-fallback-regexp-alist | ||
| 396 | `(;; Use a tight regexp to handle weird file names (with colons | ||
| 364 | ;; in them) as well as possible. E.g., use [1-9][0-9]* rather | 397 | ;; in them) as well as possible. E.g., use [1-9][0-9]* rather |
| 365 | ;; than [0-9]+ so as to accept ":034:" in file names. | 398 | ;; than [0-9]+ so as to accept ":034:" in file names. |
| 366 | ("^\\(.*?[^/\n]\\):[ \t]*\\([1-9][0-9]*\\)[ \t]*:" | 399 | ("^\\(.*?[^/\n]\\):[ \t]*\\([1-9][0-9]*\\)[ \t]*:" |
| 367 | 1 2 | 400 | 1 2 ,grep--regexp-alist-column) |
| 368 | ;; Calculate column positions (col . end-col) of first grep match on a line | 401 | ,grep--regexp-alist-bin-matcher) |
| 369 | ((lambda () | 402 | "Regexp used to match grep hits when `--null' is not supported. |
| 370 | (when grep-highlight-matches | 403 | See `compilation-error-regexp-alist'.") |
| 371 | (let* ((beg (match-end 0)) | 404 | |
| 372 | (end (save-excursion (goto-char beg) (line-end-position))) | 405 | (defvaralias 'grep-regex-alist 'grep-with-null-regexp-alist) |
| 373 | (mbeg (text-property-any beg end 'font-lock-face grep-match-face))) | 406 | (make-obsolete-variable |
| 374 | (when mbeg | 407 | 'grep-regex-alist "Call `grep-regexp-alist' instead." "26.1") |
| 375 | (- mbeg beg))))) | 408 | |
| 376 | . | 409 | ;;;###autoload |
| 377 | (lambda () | 410 | (defun grep-regexp-alist () |
| 378 | (when grep-highlight-matches | 411 | "Return a regexp alist to match grep hits. |
| 379 | (let* ((beg (match-end 0)) | 412 | The regexp used depends on `grep-use-null-filename-separator'. |
| 380 | (end (save-excursion (goto-char beg) (line-end-position))) | 413 | See `compilation-error-regexp-alist' for format details." |
| 381 | (mbeg (text-property-any beg end 'font-lock-face grep-match-face)) | 414 | (if grep-use-null-filename-separator |
| 382 | (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end)))) | 415 | grep-with-null-regexp-alist grep-fallback-regexp-alist)) |
| 383 | (when mend | ||
| 384 | (- mend beg))))))) | ||
| 385 | ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1)) | ||
| 386 | "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") | ||
| 387 | 416 | ||
| 388 | (defvar grep-first-column 0 ; bug#10594 | 417 | (defvar grep-first-column 0 ; bug#10594 |
| 389 | "Value to use for `compilation-first-column' in grep buffers.") | 418 | "Value to use for `compilation-first-column' in grep buffers.") |
| @@ -538,6 +567,8 @@ This function is called from `compilation-filter-hook'." | |||
| 538 | (grep-use-null-device ,grep-use-null-device) | 567 | (grep-use-null-device ,grep-use-null-device) |
| 539 | (grep-find-command ,grep-find-command) | 568 | (grep-find-command ,grep-find-command) |
| 540 | (grep-find-template ,grep-find-template) | 569 | (grep-find-template ,grep-find-template) |
| 570 | (grep-use-null-filename-separator | ||
| 571 | ,grep-use-null-filename-separator) | ||
| 541 | (grep-find-use-xargs ,grep-find-use-xargs) | 572 | (grep-find-use-xargs ,grep-find-use-xargs) |
| 542 | (grep-highlight-matches ,grep-highlight-matches))))) | 573 | (grep-highlight-matches ,grep-highlight-matches))))) |
| 543 | (let* ((host-id | 574 | (let* ((host-id |
| @@ -550,7 +581,8 @@ This function is called from `compilation-filter-hook'." | |||
| 550 | ;; computed for every host once. | 581 | ;; computed for every host once. |
| 551 | (dolist (setting '(grep-command grep-template | 582 | (dolist (setting '(grep-command grep-template |
| 552 | grep-use-null-device grep-find-command | 583 | grep-use-null-device grep-find-command |
| 553 | grep-find-template grep-find-use-xargs | 584 | grep-use-null-filename-separator |
| 585 | grep-find-template grep-find-use-xargs | ||
| 554 | grep-highlight-matches)) | 586 | grep-highlight-matches)) |
| 555 | (set setting | 587 | (set setting |
| 556 | (cadr (or (assq setting host-defaults) | 588 | (cadr (or (assq setting host-defaults) |
| @@ -576,6 +608,21 @@ This function is called from `compilation-filter-hook'." | |||
| 576 | (concat (regexp-quote hello-file) | 608 | (concat (regexp-quote hello-file) |
| 577 | ":[0-9]+:English"))))))))) | 609 | ":[0-9]+:English"))))))))) |
| 578 | 610 | ||
| 611 | (when (eq grep-use-null-filename-separator 'auto-detect) | ||
| 612 | (setq grep-use-null-filename-separator | ||
| 613 | (with-temp-buffer | ||
| 614 | (let* ((hello-file (expand-file-name "HELLO" data-directory)) | ||
| 615 | (args `("--null" "-ne" "^English" ,hello-file))) | ||
| 616 | (if grep-use-null-device | ||
| 617 | (setq args (append args (list null-device))) | ||
| 618 | (push "-H" args)) | ||
| 619 | (and (grep-probe grep-program `(nil t nil ,@args)) | ||
| 620 | (progn | ||
| 621 | (goto-char (point-min)) | ||
| 622 | (looking-at | ||
| 623 | (concat (regexp-quote hello-file) | ||
| 624 | "\0[0-9]+:English")))))))) | ||
| 625 | |||
| 579 | (when (eq grep-highlight-matches 'auto-detect) | 626 | (when (eq grep-highlight-matches 'auto-detect) |
| 580 | (setq grep-highlight-matches | 627 | (setq grep-highlight-matches |
| 581 | (with-temp-buffer | 628 | (with-temp-buffer |
| @@ -591,6 +638,7 @@ This function is called from `compilation-filter-hook'." | |||
| 591 | grep-template grep-find-template) | 638 | grep-template grep-find-template) |
| 592 | (let ((grep-options | 639 | (let ((grep-options |
| 593 | (concat (if grep-use-null-device "-n" "-nH") | 640 | (concat (if grep-use-null-device "-n" "-nH") |
| 641 | (if grep-use-null-filename-separator " --null") | ||
| 594 | (if (grep-probe grep-program | 642 | (if (grep-probe grep-program |
| 595 | `(nil nil nil "-e" "foo" ,null-device) | 643 | `(nil nil nil "-e" "foo" ,null-device) |
| 596 | nil 1) | 644 | nil 1) |
| @@ -733,7 +781,7 @@ This function is called from `compilation-filter-hook'." | |||
| 733 | (set (make-local-variable 'compilation-error-face) | 781 | (set (make-local-variable 'compilation-error-face) |
| 734 | grep-hit-face) | 782 | grep-hit-face) |
| 735 | (set (make-local-variable 'compilation-error-regexp-alist) | 783 | (set (make-local-variable 'compilation-error-regexp-alist) |
| 736 | grep-regexp-alist) | 784 | (grep-regexp-alist)) |
| 737 | ;; compilation-directory-matcher can't be nil, so we set it to a regexp that | 785 | ;; compilation-directory-matcher can't be nil, so we set it to a regexp that |
| 738 | ;; can never match. | 786 | ;; can never match. |
| 739 | (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) | 787 | (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) |
diff --git a/lisp/progmodes/ld-script.el b/lisp/progmodes/ld-script.el index 389ddfca6b1..7a666e95297 100644 --- a/lisp/progmodes/ld-script.el +++ b/lisp/progmodes/ld-script.el | |||
| @@ -85,10 +85,12 @@ | |||
| 85 | ;; 3.4.5 Other Linker Script Commands | 85 | ;; 3.4.5 Other Linker Script Commands |
| 86 | "ASSERT" "EXTERN" "FORCE_COMMON_ALLOCATION" | 86 | "ASSERT" "EXTERN" "FORCE_COMMON_ALLOCATION" |
| 87 | "INHIBIT_COMMON_ALLOCATION" "INSERT" "AFTER" "BEFORE" | 87 | "INHIBIT_COMMON_ALLOCATION" "INSERT" "AFTER" "BEFORE" |
| 88 | "NOCROSSREFS" "OUTPUT_ARCH" "LD_FEATURE" | 88 | "NOCROSSREFS" "NOCROSSREFS_TO" "OUTPUT_ARCH" "LD_FEATURE" |
| 89 | ;; 3.5.2 PROVIDE | 89 | ;; 3.5.2 HIDDEN |
| 90 | "HIDDEN" | ||
| 91 | ;; 3.5.3 PROVIDE | ||
| 90 | "PROVIDE" | 92 | "PROVIDE" |
| 91 | ;; 3.5.3 PROVIDE_HIDDEN | 93 | ;; 3.5.4 PROVIDE_HIDDEN |
| 92 | "PROVIDE_HIDDEN" | 94 | "PROVIDE_HIDDEN" |
| 93 | ;; 3.6 SECTIONS Command | 95 | ;; 3.6 SECTIONS Command |
| 94 | "SECTIONS" | 96 | "SECTIONS" |
| @@ -142,6 +144,7 @@ | |||
| 142 | "DEFINED" | 144 | "DEFINED" |
| 143 | "LENGTH" "len" "l" | 145 | "LENGTH" "len" "l" |
| 144 | "LOADADDR" | 146 | "LOADADDR" |
| 147 | "LOG2CEIL" | ||
| 145 | "MAX" | 148 | "MAX" |
| 146 | "MIN" | 149 | "MIN" |
| 147 | "NEXT" | 150 | "NEXT" |
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 3def37a2ea8..6197a53ee66 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el | |||
| @@ -213,25 +213,6 @@ | |||
| 213 | (regexp-opt perl--syntax-exp-intro-keywords) | 213 | (regexp-opt perl--syntax-exp-intro-keywords) |
| 214 | "\\|[-?:.,;|&+*=!~({[]\\|\\(^\\)\\)[ \t\n]*"))) | 214 | "\\|[-?:.,;|&+*=!~({[]\\|\\(^\\)\\)[ \t\n]*"))) |
| 215 | 215 | ||
| 216 | ;; FIXME: handle here-docs and regexps. | ||
| 217 | ;; <<EOF <<"EOF" <<'EOF' (no space) | ||
| 218 | ;; see `man perlop' | ||
| 219 | ;; ?...? | ||
| 220 | ;; /.../ | ||
| 221 | ;; m [...] | ||
| 222 | ;; m /.../ | ||
| 223 | ;; q /.../ = '...' | ||
| 224 | ;; qq /.../ = "..." | ||
| 225 | ;; qx /.../ = `...` | ||
| 226 | ;; qr /.../ = precompiled regexp =~=~ m/.../ | ||
| 227 | ;; qw /.../ | ||
| 228 | ;; s /.../.../ | ||
| 229 | ;; s <...> /.../ | ||
| 230 | ;; s '...'...' | ||
| 231 | ;; tr /.../.../ | ||
| 232 | ;; y /.../.../ | ||
| 233 | ;; | ||
| 234 | ;; <file*glob> | ||
| 235 | (defun perl-syntax-propertize-function (start end) | 216 | (defun perl-syntax-propertize-function (start end) |
| 236 | (let ((case-fold-search nil)) | 217 | (let ((case-fold-search nil)) |
| 237 | (goto-char start) | 218 | (goto-char start) |
| @@ -324,23 +305,25 @@ | |||
| 324 | ((concat | 305 | ((concat |
| 325 | "\\(?:" | 306 | "\\(?:" |
| 326 | ;; << "EOF", << 'EOF', or << \EOF | 307 | ;; << "EOF", << 'EOF', or << \EOF |
| 327 | "<<[ \t]*\\('[^'\n]*'\\|\"[^\"\n]*\"\\|\\\\[[:alpha:]][[:alnum:]]*\\)" | 308 | "<<\\(~\\)?[ \t]*\\('[^'\n]*'\\|\"[^\"\n]*\"\\|\\\\[[:alpha:]][[:alnum:]]*\\)" |
| 328 | ;; The <<EOF case which needs perl--syntax-exp-intro-regexp, to | 309 | ;; The <<EOF case which needs perl--syntax-exp-intro-regexp, to |
| 329 | ;; disambiguate with the left-bitshift operator. | 310 | ;; disambiguate with the left-bitshift operator. |
| 330 | "\\|" perl--syntax-exp-intro-regexp "<<\\(?1:\\sw+\\)\\)" | 311 | "\\|" perl--syntax-exp-intro-regexp "<<\\(?2:\\sw+\\)\\)" |
| 331 | ".*\\(\n\\)") | 312 | ".*\\(\n\\)") |
| 332 | (3 (let* ((st (get-text-property (match-beginning 3) 'syntax-table)) | 313 | (4 (let* ((st (get-text-property (match-beginning 4) 'syntax-table)) |
| 333 | (name (match-string 1))) | 314 | (name (match-string 2)) |
| 334 | (goto-char (match-end 1)) | 315 | (indented (match-beginning 1))) |
| 316 | (goto-char (match-end 2)) | ||
| 335 | (if (save-excursion (nth 8 (syntax-ppss (match-beginning 0)))) | 317 | (if (save-excursion (nth 8 (syntax-ppss (match-beginning 0)))) |
| 336 | ;; Leave the property of the newline unchanged. | 318 | ;; Leave the property of the newline unchanged. |
| 337 | st | 319 | st |
| 338 | (cons (car (string-to-syntax "< c")) | 320 | (cons (car (string-to-syntax "< c")) |
| 339 | ;; Remember the names of heredocs found on this line. | 321 | ;; Remember the names of heredocs found on this line. |
| 340 | (cons (pcase (aref name 0) | 322 | (cons (cons (pcase (aref name 0) |
| 341 | (`?\\ (substring name 1)) | 323 | (`?\\ (substring name 1)) |
| 342 | ((or `?\" `?\' `?\`) (substring name 1 -1)) | 324 | ((or `?\" `?\' `?\`) (substring name 1 -1)) |
| 343 | (_ name)) | 325 | (_ name)) |
| 326 | indented) | ||
| 344 | (cdr st))))))) | 327 | (cdr st))))))) |
| 345 | ;; We don't call perl-syntax-propertize-special-constructs directly | 328 | ;; We don't call perl-syntax-propertize-special-constructs directly |
| 346 | ;; from the << rule, because there might be other elements (between | 329 | ;; from the << rule, because there might be other elements (between |
| @@ -383,7 +366,9 @@ | |||
| 383 | (goto-char (nth 8 state))) | 366 | (goto-char (nth 8 state))) |
| 384 | (while (and names | 367 | (while (and names |
| 385 | (re-search-forward | 368 | (re-search-forward |
| 386 | (concat "^" (regexp-quote (pop names)) "\n") | 369 | (pcase-let ((`(,name . ,indented) (pop names))) |
| 370 | (concat "^" (if indented "[ \t]*") | ||
| 371 | (regexp-quote name) "\n")) | ||
| 387 | limit 'move)) | 372 | limit 'move)) |
| 388 | (unless names | 373 | (unless names |
| 389 | (put-text-property (1- (point)) (point) 'syntax-table | 374 | (put-text-property (1- (point)) (point) 'syntax-table |
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index b8ec50f14ae..cc9b794c5a0 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -917,20 +917,21 @@ IGNORES is a list of glob patterns." | |||
| 917 | (grep-compute-defaults) | 917 | (grep-compute-defaults) |
| 918 | (defvar grep-find-template) | 918 | (defvar grep-find-template) |
| 919 | (defvar grep-highlight-matches) | 919 | (defvar grep-highlight-matches) |
| 920 | (let* ((grep-find-template (replace-regexp-in-string "<C>" "<C> -E" | 920 | (pcase-let* |
| 921 | grep-find-template t t)) | 921 | ((grep-find-template (replace-regexp-in-string "<C>" "<C> -E" |
| 922 | (grep-highlight-matches nil) | 922 | grep-find-template t t)) |
| 923 | ;; TODO: Sanitize the regexp to remove Emacs-specific terms, | 923 | (grep-highlight-matches nil) |
| 924 | ;; so that Grep can search for the "relaxed" version. Can we | 924 | ;; TODO: Sanitize the regexp to remove Emacs-specific terms, |
| 925 | ;; do that reliably enough, without creating false negatives? | 925 | ;; so that Grep can search for the "relaxed" version. Can we |
| 926 | (command (xref--rgrep-command (xref--regexp-to-extended regexp) | 926 | ;; do that reliably enough, without creating false negatives? |
| 927 | files | 927 | (command (xref--rgrep-command (xref--regexp-to-extended regexp) |
| 928 | (expand-file-name dir) | 928 | files |
| 929 | ignores)) | 929 | (expand-file-name dir) |
| 930 | (buf (get-buffer-create " *xref-grep*")) | 930 | ignores)) |
| 931 | (grep-re (caar grep-regexp-alist)) | 931 | (buf (get-buffer-create " *xref-grep*")) |
| 932 | status | 932 | (`(,grep-re ,file-group ,line-group . ,_) (car (grep-regexp-alist))) |
| 933 | hits) | 933 | (status nil) |
| 934 | (hits nil)) | ||
| 934 | (with-current-buffer buf | 935 | (with-current-buffer buf |
| 935 | (erase-buffer) | 936 | (erase-buffer) |
| 936 | (setq status | 937 | (setq status |
| @@ -944,8 +945,8 @@ IGNORES is a list of glob patterns." | |||
| 944 | (not (looking-at grep-re))) | 945 | (not (looking-at grep-re))) |
| 945 | (user-error "Search failed with status %d: %s" status (buffer-string))) | 946 | (user-error "Search failed with status %d: %s" status (buffer-string))) |
| 946 | (while (re-search-forward grep-re nil t) | 947 | (while (re-search-forward grep-re nil t) |
| 947 | (push (list (string-to-number (match-string 2)) | 948 | (push (list (string-to-number (match-string line-group)) |
| 948 | (match-string 1) | 949 | (match-string file-group) |
| 949 | (buffer-substring-no-properties (point) (line-end-position))) | 950 | (buffer-substring-no-properties (point) (line-end-position))) |
| 950 | hits))) | 951 | hits))) |
| 951 | (xref--convert-hits (nreverse hits) regexp))) | 952 | (xref--convert-hits (nreverse hits) regexp))) |