aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/cus-start.el2
-rw-r--r--lisp/frame.el2
-rw-r--r--lisp/progmodes/cc-cmds.el27
-rw-r--r--lisp/progmodes/cc-defs.el12
-rw-r--r--lisp/progmodes/cc-engine.el9
-rw-r--r--lisp/progmodes/cc-mode.el66
6 files changed, 73 insertions, 45 deletions
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index e0290395ade..ed913e32688 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -594,7 +594,7 @@ since it could result in memory overflow and make Emacs crash."
594 (const :tag "Visually relative line numbers" 594 (const :tag "Visually relative line numbers"
595 :value visual)) 595 :value visual))
596 "26.1") 596 "26.1")
597 (display-line-number-width display 597 (display-line-numbers-width display
598 (choice 598 (choice
599 (const :tag "Dynamically computed" 599 (const :tag "Dynamically computed"
600 :value nil) 600 :value nil)
diff --git a/lisp/frame.el b/lisp/frame.el
index 0e9f38589f9..7d571791e23 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2473,7 +2473,7 @@ See also `toggle-frame-maximized'."
2473 wrap-prefix 2473 wrap-prefix
2474 truncate-lines 2474 truncate-lines
2475 display-line-numbers 2475 display-line-numbers
2476 display-line-number-width 2476 display-line-numbers-width
2477 display-line-numbers-current-absolute 2477 display-line-numbers-current-absolute
2478 display-line-numbers-widen 2478 display-line-numbers-widen
2479 bidi-paragraph-direction 2479 bidi-paragraph-direction
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..22f5b906e4e 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6091,6 +6091,13 @@ comment at the start of cc-engine.el for more info."
6091 ;; Clears `c-found-types'. 6091 ;; Clears `c-found-types'.
6092 (setq c-found-types (make-vector 53 0))) 6092 (setq c-found-types (make-vector 53 0)))
6093 6093
6094(defun c-copy-found-types ()
6095 (let ((copy (make-vector 53 0)))
6096 (mapatoms (lambda (sym)
6097 (intern (symbol-name sym) copy))
6098 c-found-types)
6099 copy))
6100
6094(defun c-add-type (from to) 6101(defun c-add-type (from to)
6095 ;; Add the given region as a type in `c-found-types'. If the region 6102 ;; Add the given region as a type in `c-found-types'. If the region
6096 ;; doesn't match an existing type but there is a type which is equal 6103 ;; doesn't match an existing type but there is a type which is equal
@@ -7059,6 +7066,7 @@ comment at the start of cc-engine.el for more info."
7059 ;; This function might do hidden buffer changes. 7066 ;; This function might do hidden buffer changes.
7060 7067
7061 (let ((start (point)) 7068 (let ((start (point))
7069 (old-found-types (c-copy-found-types))
7062 ;; If `c-record-type-identifiers' is set then activate 7070 ;; If `c-record-type-identifiers' is set then activate
7063 ;; recording of any found types that constitute an argument in 7071 ;; recording of any found types that constitute an argument in
7064 ;; the arglist. 7072 ;; the arglist.
@@ -7074,6 +7082,7 @@ comment at the start of cc-engine.el for more info."
7074 (nconc c-record-found-types c-record-type-identifiers))) 7082 (nconc c-record-found-types c-record-type-identifiers)))
7075 t) 7083 t)
7076 7084
7085 (setq c-found-types old-found-types)
7077 (goto-char start) 7086 (goto-char start)
7078 nil))) 7087 nil)))
7079 7088
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