From 01a98e918de8b6e3cc8664dd99f02715dc41854b Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Wed, 12 Jul 2017 17:35:31 +0200 Subject: [PATCH 1/6] Minor tweaks of new line number display variables * src/xdisp.c (Vdisplay_line_numbers): Tweak doc-string. (Vdisplay_line_number_width): Rename to Vdisplay_line_numbers_width. (maybe_produce_line_number): Comply with above rename. * lisp/cus-start.el (standard): * lisp/frame.el (top-level): * etc/NEWS: Comply with renaming of `display-line-number-width' to `display-line-numbers-width'. --- etc/NEWS | 2 +- lisp/cus-start.el | 2 +- lisp/frame.el | 2 +- src/xdisp.c | 39 +++++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 68ebdb3c15c..71a2da1b637 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -442,7 +442,7 @@ new face 'line-number-current-line' can be customized to display the current line's number differently from all the other line numbers; by default these two faces are identical. -You can also customize the new variable 'display-line-number-width' to +You can also customize the new variable 'display-line-numbers-width' to specify a fixed minimal with of the area allocated to line-number display. The default is nil, meaning that Emacs will dynamically calculate the area width, enlarging or shrinking it as needed. 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." (const :tag "Visually relative line numbers" :value visual)) "26.1") - (display-line-number-width display + (display-line-numbers-width display (choice (const :tag "Dynamically computed" :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'." wrap-prefix truncate-lines display-line-numbers - display-line-number-width + display-line-numbers-width display-line-numbers-current-absolute display-line-numbers-widen bidi-paragraph-direction diff --git a/src/xdisp.c b/src/xdisp.c index 91e9d8abcee..6b0532d95f5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -20904,8 +20904,8 @@ maybe_produce_line_number (struct it *it) /* Compute the required width if needed. */ if (!it->lnum_width) { - if (NATNUMP (Vdisplay_line_number_width)) - it->lnum_width = XFASTINT (Vdisplay_line_number_width); + if (NATNUMP (Vdisplay_line_numbers_width)) + it->lnum_width = XFASTINT (Vdisplay_line_numbers_width); /* Max line number to be displayed cannot be more than the one corresponding to the last row of the desired matrix. */ @@ -32686,35 +32686,38 @@ To add a prefix to continuation lines, use `wrap-prefix'. */); DEFVAR_LISP ("display-line-numbers", Vdisplay_line_numbers, doc: /* Non-nil means display line numbers. -If the value is t, display absolute line numbers starting at the -beginning of the current narrowing, or at buffer beginning. -If the value is `relative', display line numbers relative to the -line showing point. -The value `visual' countse lative screen lines rather than -physical line: by default, line numbers are displayed before each -non-continuation line that displays buffer text, i.e. after each -newline that came from buffer text. However, if the value is `visual', -every screen line will have a number. +If the value is t, display the absolute number of each line of a buffer +shown in a window. Absolute line numbers count from the beginning of +the current narrowing, or from buffer beginning. If the value is +`relative', display for each line not containing the window's point its +relative number instead, i.e. the number of the line relative to the +line showing the window's point. + +In either case, line numbers are displayed at the beginning of each +non-continuation line that displays buffer text, i.e. after each newline +character that comes from the buffer. The value `visual' is like +`relative' but counts screen lines instead of buffer lines. In practice +this means that continuation lines count as well when calculating the +relative number of a line. Lisp programs can disable display of a line number of a particular -screen line by putting the `display-line-numbers-disable' text -property or overlay property on the first visible character of -that line. */); +buffer line by putting the `display-line-numbers-disable' text property +or overlay property on the first visible character of that line. */); Vdisplay_line_numbers = Qnil; DEFSYM (Qdisplay_line_numbers, "display-line-numbers"); Fmake_variable_buffer_local (Qdisplay_line_numbers); DEFSYM (Qrelative, "relative"); DEFSYM (Qvisual, "visual"); - DEFVAR_LISP ("display-line-number-width", Vdisplay_line_number_width, + DEFVAR_LISP ("display-line-numbers-width", Vdisplay_line_numbers_width, doc: /* Minimum width of space reserved for line number display. A positive number means reserve that many columns for line numbers, even if the actual number needs less space. The default value of nil means compute the space dynamically. Any other value is treated as nil. */); - Vdisplay_line_number_width = Qnil; - DEFSYM (Qdisplay_line_number_width, "display-line-number-width"); - Fmake_variable_buffer_local (Qdisplay_line_number_width); + Vdisplay_line_numbers_width = Qnil; + DEFSYM (Qdisplay_line_numbers_width, "display-line-number-width"); + Fmake_variable_buffer_local (Qdisplay_line_numbers_width); DEFVAR_LISP ("display-line-numbers-current-absolute", Vdisplay_line_numbers_current_absolute, From 125a8a62db96c5e3c3e93c34fdb1429098b0d3f6 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Wed, 12 Jul 2017 17:03:35 +0000 Subject: [PATCH 2/6] CC Mode: create and use c-set-keymap-parent. * lisp/progmodes/cc-defs.el (c-set-keymap-parent): New macro. * lisp/progmodes/cc-mode.el (top-level): Remove cc-bytecomp-defun for set-keymap-parents. (c-make-inherited-keymap): Use c-set-keymap-parent in place of inline code. --- lisp/progmodes/cc-defs.el | 12 ++++++++++++ lisp/progmodes/cc-mode.el | 13 +------------ 2 files changed, 13 insertions(+), 12 deletions(-) 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." ;; Emacs. `(setq mark-active ,activate))) +(defmacro c-set-keymap-parent (map parent) + (cond + ;; XEmacs + ((cc-bytecomp-fboundp 'set-keymap-parents) + `(set-keymap-parents ,map ,parent)) + ;; Emacs + ((cc-bytecomp-fboundp 'set-keymap-parent) + `(set-keymap-parent ,map ,parent)) + ;; incompatible + (t (error "CC Mode is incompatible with this version of Emacs")))) + (defmacro c-delete-and-extract-region (start end) "Delete the text between START and END and return it." (if (cc-bytecomp-fboundp 'delete-and-extract-region) @@ -1266,6 +1277,7 @@ with value CHAR in the region [FROM to)." (def-edebug-spec cc-eval-when-compile (&rest def-form)) (def-edebug-spec c-point t) (def-edebug-spec c-set-region-active t) +(def-edebug-spec c-set-keymap-parent t) (def-edebug-spec c-safe t) (def-edebug-spec c-save-buffer-state let*) (def-edebug-spec c-tentative-buffer-changes t) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 9b89681c3bf..1150ebd33b5 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." (defun c-make-inherited-keymap () (let ((map (make-sparse-keymap))) - ;; Necessary to use `cc-bytecomp-fboundp' below since this - ;; function is called from top-level forms that are evaluated - ;; while cc-bytecomp is active when one does M-x eval-buffer. - (cond - ;; Emacs - ((cc-bytecomp-fboundp 'set-keymap-parent) - (set-keymap-parent map c-mode-base-map)) - ;; XEmacs - ((fboundp 'set-keymap-parents) - (set-keymap-parents map c-mode-base-map)) - ;; incompatible - (t (error "CC Mode is incompatible with this version of Emacs"))) + (c-set-keymap-parent map c-mode-base-map) map)) (defun c-define-abbrev-table (name defs &optional doc) From 7dd72d76effad5198c0d43a2b68aafbfe34b5ee7 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Wed, 12 Jul 2017 17:42:12 +0000 Subject: [PATCH 3/6] Make prog-mode-map the parent of c-mode-base-map. Fixes bug #26658. * lisp/progmodes/cc-mode.el (top level): Make prog-mode-map the parent of c-mode-base-map if possible. --- lisp/progmodes/cc-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 1150ebd33b5..23044b1f4f4 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -265,6 +265,8 @@ control). See \"cc-mode.el\" for more info." nil (setq c-mode-base-map (make-sparse-keymap)) + (when (boundp 'prog-mode-map) + (c-set-keymap-parent c-mode-base-map prog-mode-map)) ;; Separate M-BS from C-M-h. The former should remain ;; backward-kill-word. From dde7f2d48b53996bdf767a8cf91aafc2e10add23 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Wed, 12 Jul 2017 20:15:56 +0000 Subject: [PATCH 4/6] Fix some bugs in c-defun-name. This fixes bug #25623. * lisp/progmodes/cc-cmds.el (c-defun-name): Fix some bugs to do with structs, etc. --- lisp/progmodes/cc-cmds.el | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 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." (unless (eq where 'at-header) (c-backward-to-nth-BOF-{ 1 where) (c-beginning-of-decl-1)) + (when (looking-at c-typedef-key) + (goto-char (match-end 0)) + (c-forward-syntactic-ws)) ;; Pick out the defun name, according to the type of defun. (cond ;; struct, union, enum, or similar: - ((and (looking-at c-type-prefix-key) - (progn (c-forward-token-2 2) ; over "struct foo " - (or (eq (char-after) ?\{) - (looking-at c-symbol-key)))) ; "struct foo bar ..." - (save-match-data (c-forward-token-2)) - (when (eq (char-after) ?\{) - (c-backward-token-2) - (looking-at c-symbol-key)) - (match-string-no-properties 0)) + ((looking-at c-type-prefix-key) + (let ((key-pos (point))) + (c-forward-token-2 1) ; over "struct ". + (cond + ((looking-at c-symbol-key) ; "struct foo { ..." + (buffer-substring-no-properties key-pos (match-end 0))) + ((eq (char-after) ?{) ; "struct { ... } foo" + (when (c-go-list-forward) + (c-forward-syntactic-ws) + (when (looking-at c-symbol-key) ; a bit bogus - there might + ; be several identifiers. + (match-string-no-properties 0))))))) ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs! ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory @@ -1900,7 +1906,8 @@ with a brace block." (c-backward-syntactic-ws)) (setq name-end (point)) (c-back-over-compound-identifier) - (buffer-substring-no-properties (point) name-end))))))))) + (and (looking-at c-symbol-start) + (buffer-substring-no-properties (point) name-end)))))))))) (defun c-declaration-limits (near) ;; Return a cons of the beginning and end positions of the current From 1f08279e1b20bd1e07132b6ee0a25a154811615a Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 13 Jul 2017 16:40:07 +0200 Subject: [PATCH 5/6] ; Improve tramp-tests traces --- test/Makefile.in | 6 +++--- test/lisp/net/tramp-tests.el | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index 11373db8ca9..4e1a120d5c2 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -136,7 +136,8 @@ endif $(AM_V_ELC)$(emacs) -f batch-byte-compile $< ## Save logs, and show logs for failed tests. -WRITE_LOG = > $@ 2>&1 || { STAT=$$?; cat $@; exit $$STAT; } +WRITE_LOG = $(if $(and ${NIX_STORE}, $(findstring tramp, $@)), |& tee $@, > $@ 2>&1) \ + || { STAT=$$?; cat $@; exit $$STAT; } ifeq ($(TEST_LOAD_EL), yes) testloadfile = $*.el @@ -147,8 +148,7 @@ endif %.log: %.elc $(AM_V_at)${MKDIR_P} $(dir $@) $(AM_V_GEN)HOME=/nonexistent $(emacs) -l ert -l $(testloadfile) \ - --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" \ - $(if $(and ${NIX_STORE}, $(findstring tramp, $(testloadfile))), , ${WRITE_LOG}) + --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} ifeq (@HAVE_MODULES@, yes) maybe_exclude_module_tests := diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 8001d9433a0..263e1359066 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -3787,9 +3787,15 @@ process sentinels. They shall not disturb each other." (should-not (file-attributes file)) (should (file-attributes file))) ;; Send string to process. + (tramp--test-message + "Trace 1 action %d %s %s" count buf (current-time-string)) (process-send-string proc (format "%s\n" (buffer-name buf))) + (tramp--test-message + "Trace 2 action %d %s %s" count buf (current-time-string)) (accept-process-output proc 0.1 nil 0) ;; Regular operation. + (tramp--test-message + "Trace 3 action %d %s %s" count buf (current-time-string)) (if (= count 2) (should-not (file-attributes file)) (should (file-attributes file))) From 7eef16a923fa54ec0a88e00e75176a844dbd2944 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Thu, 13 Jul 2017 19:56:00 +0000 Subject: [PATCH 6/6] C++ Mode. Fix anomaly occurring when a ">" is deleted then reinserted. This fontification anomaly happened because after deleting the ">", c-forward-<>-arglist parses the preceding identifier as a putative type but stores it in c-found-types before it becomes clear it is not an unambiguous type. c-forward-<>-arglist fails, leaving the spurious type id in c-found-types. Fix this by "binding" c-found-types "to itself" in c-forward-<>-arglist, and restoring the original value when that function call fails. * lisp/progmodes/cc-engine.el (c-copy-found-types): New function. (c-forward-<>-arglist): Record the original value of c-found-types at the beginning of the function, and restore it at the end on failure. * lisp/progmodes/cc-mode.el (c-unfind-coalesced-tokens): Rewrite more accurately. --- lisp/progmodes/cc-engine.el | 9 +++++++ lisp/progmodes/cc-mode.el | 51 ++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 21 deletions(-) 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." ;; Clears `c-found-types'. (setq c-found-types (make-vector 53 0))) +(defun c-copy-found-types () + (let ((copy (make-vector 53 0))) + (mapatoms (lambda (sym) + (intern (symbol-name sym) copy)) + c-found-types) + copy)) + (defun c-add-type (from to) ;; Add the given region as a type in `c-found-types'. If the region ;; 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." ;; This function might do hidden buffer changes. (let ((start (point)) + (old-found-types (c-copy-found-types)) ;; If `c-record-type-identifiers' is set then activate ;; recording of any found types that constitute an argument in ;; the arglist. @@ -7074,6 +7082,7 @@ comment at the start of cc-engine.el for more info." (nconc c-record-found-types c-record-type-identifiers))) t) + (setq c-found-types old-found-types) (goto-char start) nil))) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 23044b1f4f4..bf0439ffe8a 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -437,27 +437,36 @@ preferably use the `c-mode-menu' language constant directly." t)))) (defun c-unfind-coalesced-tokens (beg end) - ;; unless the non-empty region (beg end) is entirely WS and there's at - ;; least one character of WS just before or after this region, remove - ;; the tokens which touch the region from `c-found-types' should they - ;; be present. - (or (c-partial-ws-p beg end) - (save-excursion - (progn - (goto-char beg) - (or (eq beg (point-min)) - (c-skip-ws-backward (1- beg)) - (/= (point) beg) - (= (c-backward-token-2) 1) - (c-unfind-type (buffer-substring-no-properties - (point) beg))) - (goto-char end) - (or (eq end (point-max)) - (c-skip-ws-forward (1+ end)) - (/= (point) end) - (progn (forward-char) (c-end-of-current-token) nil) - (c-unfind-type (buffer-substring-no-properties - end (point)))))))) + ;; If removing the region (beg end) would coalesce an identifier ending at + ;; beg with an identifier (fragment) beginning at end, or an identifier + ;; fragment ending at beg with an identifier beginning at end, remove the + ;; pertinent identifier(s) from `c-found-types'. + (save-excursion + (when (< beg end) + (goto-char beg) + (when + (and (not (bobp)) + (progn (c-backward-syntactic-ws) (eq (point) beg)) + (/= (skip-chars-backward c-symbol-chars (1- (point))) 0) + (progn (goto-char beg) (c-forward-syntactic-ws) (<= (point) end)) + (> (point) beg) + (goto-char end) + (looking-at c-symbol-char-key)) + (goto-char beg) + (c-simple-skip-symbol-backward) + (c-unfind-type (buffer-substring-no-properties (point) beg))) + + (goto-char end) + (when + (and (not (eobp)) + (progn (c-forward-syntactic-ws) (eq (point) end)) + (looking-at c-symbol-char-key) + (progn (c-backward-syntactic-ws) (>= (point) beg)) + (< (point) end) + (/= (skip-chars-backward c-symbol-chars (1- (point))) 0)) + (goto-char (1+ end)) + (c-end-of-current-token) + (c-unfind-type (buffer-substring-no-properties end (point))))))) ;; c-maybe-stale-found-type records a place near the region being ;; changed where an element of `found-types' might become stale. It