From 781f276cc12a204ec7db9ffd30d22a9a18c0fe94 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 8 Nov 2017 21:30:26 -0800 Subject: Fix URL cookie expiration bug Problem reported by Damien Cassou (Bug#29223). * lisp/url/url-cookie.el (url-cookie-expired-p): Fix typo in previous change, which caused unexpired cookies to be treated as expired and vice versa. --- lisp/url/url-cookie.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index 28dfcedeaca..d922033d820 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -161,7 +161,7 @@ telling Microsoft that." (let ((exp (url-cookie-expires cookie))) (and (> (length exp) 0) (condition-case () - (time-less-p nil (date-to-time exp)) + (time-less-p (date-to-time exp) nil) (error nil))))) (defun url-cookie-retrieve (host &optional localpart secure) -- cgit v1.2.3 From fc56bea1420266ea6495a2e74df28349458b6fb0 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Thu, 9 Nov 2017 18:34:13 +0000 Subject: Correctly indent C++14 brace lists which are a second argument to a function. In particular, don't indent contained brace lists in "staircase" fashion. This fixes bug #28623. * lisp/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): When testing for being enclosed in parens, recognise also a brace directly following a comma, as well as a brace being the first thing inside the paren. Enhance the return value, by indicating when we're directly inside an open paren. (c-inside-bracelist-p): Add an extra argument ACCEPT-IN-PARAM which indicates whether we will accept a bracelist directly inside an open parenthesis. Simplify the manipulation of PAREN-STATE by dispensing with variable LIM and using c-pull-open-brace. Enhance the return value, respecting the new argument. (c-guess-basic-syntax): Save a copy of the initial parse-state in the new variable STATE-CACHE. Use this variable in place of C-STATE-CACHE throughout the function. At CASE 7B, call c-inside-bracelist-p with extra argument nil. At CASE 9, call that function with extra argument t. --- lisp/progmodes/cc-engine.el | 105 ++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 47 deletions(-) (limited to 'lisp') diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 6f39cc64338..982be3bb3b9 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10407,16 +10407,20 @@ comment at the start of cc-engine.el for more info." (defun c-looking-at-or-maybe-in-bracelist (&optional containing-sexp lim) ;; Point is at an open brace. If this starts a brace list, return a list ;; whose car is the buffer position of the start of the construct which - ;; introduces the list, and whose cdr is t if we have parsed a keyword - ;; matching `c-opt-inexpr-brace-list-key' (e.g. Java's "new"), nil - ;; otherwise. Otherwise, if point might be inside an enclosing brace list, - ;; return t. If point is definitely neither at nor in a brace list, return - ;; nil. + ;; introduces the list, and whose cdr is the symbol `in-paren' if the brace + ;; is directly enclosed in a parenthesis form (i.e. an arglist), t if we + ;; have parsed a keyword matching `c-opt-inexpr-brace-list-key' (e.g. Java's + ;; "new"), nil otherwise. Otherwise, if point might be inside an enclosing + ;; brace list, return t. If point is definitely neither at nor in a brace + ;; list, return nil. ;; ;; CONTAINING-SEXP is the position of the brace/paren/bracket enclosing ;; POINT, or nil if there is no such position, or we do not know it. LIM is ;; a backward search limit. ;; + ;; The determination of whether the brace starts a brace list is solely by + ;; the context of the brace, not by its contents. + ;; ;; Here, "brace list" does not include the body of an enum. (save-excursion (let ((start (point)) @@ -10426,17 +10430,20 @@ comment at the start of cc-engine.el for more info." (and (c-major-mode-is 'pike-mode) c-decl-block-key)) (braceassignp 'dontknow) - inexpr-brace-list bufpos macro-start res pos after-type-id-pos) + inexpr-brace-list bufpos macro-start res pos after-type-id-pos + in-paren) (setq res (c-backward-token-2 1 t lim)) ;; Checks to do only on the first sexp before the brace. ;; Have we a C++ initialization, without an "="? (if (and (c-major-mode-is 'c++-mode) (cond - ((and (not (eq res 0)) + ((and (or (not (eq res 0)) + (eq (char-after) ?,)) (c-go-up-list-backward nil lim) ; FIXME!!! Check ; `lim' 2016-07-12. (eq (char-after) ?\()) - (setq braceassignp 'c++-noassign)) + (setq braceassignp 'c++-noassign + in-paren 'in-paren)) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) ((and (looking-at c-symbol-start) @@ -10445,9 +10452,11 @@ comment at the start of cc-engine.el for more info." (t nil)) (save-excursion (cond - ((not (eq res 0)) + ((or (not (eq res 0)) + (eq (char-after) ?,)) (and (c-go-up-list-backward nil lim) ; FIXME!!! Check `lim' 2016-07-12. - (eq (char-after) ?\())) + (eq (char-after) ?\() + (setq in-paren 'in-paren))) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) (t (setq after-type-id-pos (point)) @@ -10486,7 +10495,7 @@ comment at the start of cc-engine.el for more info." (c-backward-syntactic-ws) (eq (char-before) ?\())) ;; Single identifier between '(' and '{'. We have a bracelist. - (cons after-type-id-pos nil)) + (cons after-type-id-pos 'in-paren)) (t (goto-char pos) @@ -10544,7 +10553,7 @@ comment at the start of cc-engine.el for more info." (braceassignp ;; We've hit the beginning of the aggregate list. (c-beginning-of-statement-1 containing-sexp) - (cons (point) inexpr-brace-list)) + (cons (point) (or in-paren inexpr-brace-list))) ((and after-type-id-pos (save-excursion (when (eq (char-after) ?\;) @@ -10569,7 +10578,7 @@ comment at the start of cc-engine.el for more info." nil nil)) (and (consp res) (eq (car res) after-type-id-pos)))))) - (cons bufpos inexpr-brace-list)) + (cons bufpos (or in-paren inexpr-brace-list))) ((eq (char-after) ?\;) ;; Brace lists can't contain a semicolon, so we're done. ;; (setq containing-sexp nil) @@ -10593,12 +10602,16 @@ comment at the start of cc-engine.el for more info." (t t)))) ;; The caller can go up one level. ))) -(defun c-inside-bracelist-p (containing-sexp paren-state) +(defun c-inside-bracelist-p (containing-sexp paren-state accept-in-paren) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. ;; CONTAINING-SEXP is the buffer pos of the innermost containing ;; paren. PAREN-STATE is the remainder of the state of enclosing - ;; braces + ;; braces. ACCEPT-IN-PAREN is non-nil iff we will accept as a brace + ;; list a brace directly enclosed in a parenthesis. + ;; + ;; The "brace list" here is recognized solely by its context, not by + ;; its contents. ;; ;; N.B.: This algorithm can potentially get confused by cpp macros ;; placed in inconvenient locations. It's a trade-off we make for @@ -10613,17 +10626,11 @@ comment at the start of cc-engine.el for more info." ;; this will pick up array/aggregate init lists, even if they are nested. (save-excursion (let ((bufpos t) - lim next-containing) + next-containing) (while (and (eq bufpos t) containing-sexp) (when paren-state - (if (consp (car paren-state)) - (setq lim (cdr (car paren-state)) - paren-state (cdr paren-state)) - (setq lim (car paren-state))) - (when paren-state - (setq next-containing (car paren-state) - paren-state (cdr paren-state)))) + (setq next-containing (c-pull-open-brace paren-state))) (goto-char containing-sexp) (if (c-looking-at-inexpr-block next-containing next-containing) @@ -10632,14 +10639,16 @@ comment at the start of cc-engine.el for more info." ;; containing sexp, so that c-looking-at-inexpr-block ;; doesn't check for an identifier before it. (setq bufpos nil) - (when (or (not (eq (char-after) ?{)) - (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist - next-containing lim)) - t)) - (setq containing-sexp next-containing - lim nil - next-containing nil)))) - (and (consp bufpos) (car bufpos)))))) + (if (not (eq (char-after) ?{)) + (setq bufpos nil) + (when (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist + next-containing next-containing)) + t) + (setq containing-sexp next-containing + next-containing nil))))) + (and (consp bufpos) + (or accept-in-paren (not (eq (cdr bufpos) 'in-paren))) + (car bufpos)))))) (defun c-looking-at-special-brace-list (&optional _lim) ;; If we're looking at the start of a pike-style list, i.e., `({ })', @@ -11506,6 +11515,7 @@ comment at the start of cc-engine.el for more info." ;; The paren state outside `containing-sexp', or at ;; `indent-point' if `containing-sexp' is nil. (paren-state (c-parse-state)) + (state-cache (copy-tree paren-state)) ;; There's always at most one syntactic element which got ;; an anchor pos. It's stored in syntactic-relpos. syntactic-relpos @@ -11668,7 +11678,7 @@ comment at the start of cc-engine.el for more info." (not (c-at-vsemi-p before-ws-ip)) (not (memq char-after-ip '(?\) ?\] ?,))) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (progn ;; Ought to cache the result from the @@ -11746,7 +11756,7 @@ comment at the start of cc-engine.el for more info." (if containing-sexp (progn (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (c-backward-to-block-anchor lim) (c-add-stmt-syntax 'case-label nil t lim paren-state)) @@ -11772,7 +11782,7 @@ comment at the start of cc-engine.el for more info." (containing-sexp (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (save-excursion (setq tmpsymbol @@ -11816,7 +11826,7 @@ comment at the start of cc-engine.el for more info." (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (unless (eq (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) @@ -12239,11 +12249,11 @@ comment at the start of cc-engine.el for more info." (and (eq (char-before) ?}) (save-excursion (let ((start (point))) - (if (and c-state-cache - (consp (car c-state-cache)) - (eq (cdar c-state-cache) (point))) + (if (and state-cache + (consp (car state-cache)) + (eq (cdar state-cache) (point))) ;; Speed up the backward search a bit. - (goto-char (caar c-state-cache))) + (goto-char (caar state-cache))) (c-beginning-of-decl-1 containing-sexp) ; Can't use `lim' here. (setq placeholder (point)) (if (= start (point)) @@ -12400,7 +12410,8 @@ comment at the start of cc-engine.el for more info." ((and (eq char-after-ip ?{) (progn (setq placeholder (c-inside-bracelist-p (point) - paren-state)) + paren-state + nil)) (if placeholder (setq tmpsymbol '(brace-list-open . inexpr-class)) (setq tmpsymbol '(block-open . inexpr-statement) @@ -12482,7 +12493,7 @@ comment at the start of cc-engine.el for more info." (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 7G: we are looking at just a normal arglist @@ -12523,7 +12534,7 @@ comment at the start of cc-engine.el for more info." (save-excursion (goto-char containing-sexp) (c-looking-at-special-brace-list))) - (c-inside-bracelist-p containing-sexp paren-state)))) + (c-inside-bracelist-p containing-sexp paren-state t)))) (cond ;; CASE 9A: In the middle of a special brace list opener. @@ -12571,7 +12582,7 @@ comment at the start of cc-engine.el for more info." (= (point) containing-sexp))) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-close (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim nil nil t) (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) @@ -12597,7 +12608,7 @@ comment at the start of cc-engine.el for more info." (goto-char containing-sexp)) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-intro (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim) (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) @@ -12619,7 +12630,7 @@ comment at the start of cc-engine.el for more info." ((and (not (memq char-before-ip '(?\; ?:))) (not (c-at-vsemi-p before-ws-ip)) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (save-excursion (c-beginning-of-statement-1 containing-sexp) @@ -12753,7 +12764,7 @@ comment at the start of cc-engine.el for more info." (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 17: Statement or defun catchall. @@ -12827,7 +12838,7 @@ comment at the start of cc-engine.el for more info." (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (if (/= (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) -- cgit v1.2.3 From b28de574112991bfd2234989d080e54f565a549c Mon Sep 17 00:00:00 2001 From: João Távora Date: Thu, 9 Nov 2017 20:33:02 +0000 Subject: Sort entries of the Flymake diagnostics buffer (bug#29175) Reported by Lele Gaifax . * lisp/progmodes/flymake.el (flymake--diagnostics-buffer-entries): Sort results of flymake-diagnostics. --- lisp/progmodes/flymake.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index e833cd949ee..921ac913309 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1137,7 +1137,8 @@ POS can be a buffer position or a button" (defun flymake--diagnostics-buffer-entries () (with-current-buffer flymake--diagnostics-buffer-source - (cl-loop for diag in (flymake-diagnostics) + (cl-loop for diag in + (cl-sort (flymake-diagnostics) #'< :key #'flymake-diagnostic-beg) for (line . col) = (save-excursion (goto-char (flymake--diag-beg diag)) -- cgit v1.2.3 From 72e62d3fdb2b24dd9808f49fbbd864715337d2bf Mon Sep 17 00:00:00 2001 From: João Távora Date: Thu, 9 Nov 2017 20:44:11 +0000 Subject: Protect Flymake checkdoc backend against checkdoc errors (bug#29176) The function checkdoc-current-buffer may error if there are unbalanced parens, for example, but this shouldn't disable the elisp-flymake-checkdoc backend. * lisp/progmodes/elisp-mode.el (elisp-flymake-checkdoc): Use ignore-errors. --- lisp/progmodes/elisp-mode.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 41415943a58..5ba09789097 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1615,7 +1615,11 @@ Calls REPORT-FN directly." (generate-new-buffer " *checkdoc-temp*"))) (unwind-protect (save-excursion - (checkdoc-current-buffer t)) + ;; checkdoc-current-buffer can error if there are + ;; unbalanced parens, for example, but this shouldn't + ;; disable the backend (bug#29176). + (ignore-errors + (checkdoc-current-buffer t))) (kill-buffer checkdoc-diagnostic-buffer))) (funcall report-fn (cl-loop for (text start end _unfixable) in -- cgit v1.2.3 From 535688a4181ae4052db354ce2b877507f11c9e66 Mon Sep 17 00:00:00 2001 From: João Távora Date: Thu, 9 Nov 2017 21:16:40 +0000 Subject: Flymake correctly highlights whole last line if eob (bug#29201) If a line/column pair indicates an end-of-buffer position, flymake should behave like the case where the last line of the buffer is referenced without a column indication. This behavior is currently to highlight the whole last line. * lisp/progmodes/flymake.el (flymake-diag-region): Correct conditions of fallback to the fallback-eol local function. --- lisp/progmodes/flymake.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 921ac913309..883f96747b9 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -334,7 +334,8 @@ region is invalid." (end (or (and sexp-end (not (= sexp-end beg)) sexp-end) - (ignore-errors (goto-char (1+ beg))))) + (and (< (goto-char (1+ beg)) (point-max)) + (point)))) (safe-end (or end (fallback-eol beg)))) (cons (if end beg (fallback-bol)) -- cgit v1.2.3 From 89382780e1729861d98eca6e028ca1c62662a59f Mon Sep 17 00:00:00 2001 From: João Távora Date: Thu, 9 Nov 2017 21:25:36 +0000 Subject: flymake-diag-region really returns nil if region is invalid (bug#29174) Reported by Lele Gaifax . * lisp/progmodes/flymake.el (flymake-diag-region): Really return nil if the region is invalid. --- lisp/progmodes/flymake.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 883f96747b9..ea63420dfae 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -343,7 +343,8 @@ region is invalid." (let* ((beg (fallback-bol)) (end (fallback-eol beg))) (cons beg end))))))) - (error (flymake-log :warning "Invalid region line=%s col=%s" line col)))) + (error (flymake-log :warning "Invalid region line=%s col=%s") + nil))) (defvar flymake-diagnostic-functions nil "Special hook of Flymake backends that check a buffer. -- cgit v1.2.3 From e6f1fd40916afb692bd25e845ee87e73549201f4 Mon Sep 17 00:00:00 2001 From: João Távora Date: Fri, 10 Nov 2017 05:10:18 +0000 Subject: Fix previous change to flymake-diag-region (bug#29174) * lisp/progmodes/flymake.el (flymake-diag-region): Pass line and col to commit. --- lisp/progmodes/flymake.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index ea63420dfae..b4ab7f223f2 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -343,7 +343,7 @@ region is invalid." (let* ((beg (fallback-bol)) (end (fallback-eol beg))) (cons beg end))))))) - (error (flymake-log :warning "Invalid region line=%s col=%s") + (error (flymake-log :warning "Invalid region line=%s col=%s" line col) nil))) (defvar flymake-diagnostic-functions nil -- cgit v1.2.3 From e592b924824db7528b3e7764fde5c4df383b6ee8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 10 Nov 2017 12:05:08 +0200 Subject: * lisp/isearch.el (search-invisible): Doc fix. (Bug#29222) --- lisp/isearch.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/isearch.el b/lisp/isearch.el index 7c576a67d43..13fa97ea71f 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -128,9 +128,10 @@ a tab, a carriage return (control-M), a newline, and `]+'." "If t incremental search/query-replace can match hidden text. A nil value means don't match invisible text. When the value is `open', if the text matched is made invisible by -an overlay having an `invisible' property and that overlay has a property -`isearch-open-invisible', then incremental search will show the contents. -\(This applies when using `outline.el' and `hideshow.el'.) +an overlay having a non-nil `invisible' property, and that overlay +has a non-nil property `isearch-open-invisible', then incremental +search will show the hidden text. (This applies when using `outline.el' +and `hideshow.el'.) To temporarily change the value for an active incremental search, use \\\\[isearch-toggle-invisible]. -- cgit v1.2.3 From c52a2aa8f363f7f7a32119948ed73b7e4a0772ef Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 10 Nov 2017 12:12:46 +0200 Subject: Improve the doc string of 'dired-isearch-filter-filenames' * lisp/dired-aux.el (dired-isearch-filter-filenames): Doc fix. (Bug#29215) --- lisp/dired-aux.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp') diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 03639f6b507..8fb2c1ff948 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2748,9 +2748,9 @@ Intended to be added to `isearch-mode-hook'." (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) (defun dired-isearch-filter-filenames (beg end) - "Test whether the current search hit is a file name. -Return non-nil if the text from BEG to END is part of a file -name (has the text property `dired-filename')." + "Test whether some part of the current search match is inside a file name. +This function returns non-nil if some part of the text between BEG and END +is part of a file name (i.e., has the text property `dired-filename')." (text-property-not-all (min beg end) (max beg end) 'dired-filename nil)) -- cgit v1.2.3 From 096f638ddc806db875fa5bf90bb3be17b6893821 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 10 Nov 2017 17:45:22 +0000 Subject: Correct the indentation of C99's compound literals. * lisp/progmodes/cc-engine.el (c-looking-at-statement-block): Amend so that if there is only syntactic whitespace in a brace block, it is regarded as a statement block. Also, if there is no semicolon or comma delimiter, treat as a statement block when there is a keyword. (c-guess-basic-syntax): CASE 9 test: Regard a brace as starting a brace block when its contents indicate a brace block. --- lisp/progmodes/cc-engine.el | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'lisp') diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 982be3bb3b9..8ec01e1810b 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10726,26 +10726,35 @@ comment at the start of cc-engine.el for more info." (defun c-looking-at-statement-block () ;; Point is at an opening brace. If this is a statement block (i.e. the - ;; elements in it are terminated by semicolons) return t. Otherwise, return - ;; nil. + ;; elements in the block are terminated by semicolons, or the block is + ;; empty, or the block contains a keyword) return t. Otherwise, return nil. (let ((here (point))) (prog1 (if (c-go-list-forward) (let ((there (point))) (backward-char) - (c-syntactic-skip-backward - "^;," here t) + (c-syntactic-skip-backward "^;," here t) (cond ((eq (char-before) ?\;) t) ((eq (char-before) ?,) nil) - (t (goto-char here) - (forward-char) - (and (c-syntactic-re-search-forward "{" there t t) - (progn (backward-char) - (c-looking-at-statement-block)))))) + (t ; We're at (1+ here). + (cond + ((progn (c-forward-syntactic-ws) + (eq (point) (1- there))) + t) + ((c-syntactic-re-search-forward c-keywords-regexp there t) + t) + ((c-syntactic-re-search-forward "{" there t t) + (backward-char) + (c-looking-at-statement-block)) + (t nil))))) (forward-char) - (and (c-syntactic-re-search-forward "[;,]" nil t t) - (eq (char-before) ?\;))) + (cond + ((c-syntactic-re-search-forward "[;,]" nil t t) + (eq (char-before) ?\;)) + ((c-syntactic-re-search-forward c-keywords-regexp nil t t) + t) + (t nil))) (goto-char here)))) (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end) @@ -12534,7 +12543,11 @@ comment at the start of cc-engine.el for more info." (save-excursion (goto-char containing-sexp) (c-looking-at-special-brace-list))) - (c-inside-bracelist-p containing-sexp paren-state t)))) + (c-inside-bracelist-p containing-sexp paren-state t) + (save-excursion + (goto-char containing-sexp) + (and (eq (char-after) ?{) + (not (c-looking-at-statement-block))))))) (cond ;; CASE 9A: In the middle of a special brace list opener. -- cgit v1.2.3 From 44340b475f942cd65788ef9a4e75190a3646c444 Mon Sep 17 00:00:00 2001 From: Olaf Rogalsky Date: Sat, 11 Nov 2017 11:05:53 +0200 Subject: Fix "C-h k" in xterm-mouse-mode * lisp/help.el (help-read-key-sequence): Support "C-h k" for xterm-mouse-mode by calling read-key-sequence-vector instead of read-event. (Bug#29150) --- lisp/help.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/help.el b/lisp/help.el index bc8035db0ea..fbb9fc8cbe6 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -717,7 +717,7 @@ with `mouse-movement' events." (cursor-in-echo-area t) saved-yank-menu) (unwind-protect - (let (key) + (let (key down-ev) ;; If yank-menu is empty, populate it temporarily, so that ;; "Select and Paste" menu can generate a complete event. (when (null (cdr yank-menu)) @@ -743,17 +743,21 @@ Describe the following key, mouse click, or menu item: ")) (let ((last-idx (1- (length key)))) (and (eventp (aref key last-idx)) (memq 'down (event-modifiers (aref key last-idx))))) - (or (and (eventp (aref key 0)) - (memq 'down (event-modifiers (aref key 0))) + (or (and (eventp (setq down-ev (aref key 0))) + (memq 'down (event-modifiers down-ev)) ;; However, for the C-down-mouse-2 popup ;; menu, there is no subsequent up-event. In ;; this case, the up-event is the next ;; element in the supplied vector. (= (length key) 1)) (and (> (length key) 1) - (eventp (aref key 1)) - (memq 'down (event-modifiers (aref key 1))))) - (read-event)))) + (eventp (setq down-ev (aref key 1))) + (memq 'down (event-modifiers down-ev)))) + (if (and (terminal-parameter nil 'xterm-mouse-mode) + (equal (terminal-parameter nil 'xterm-mouse-last-down) + down-ev)) + (aref (read-key-sequence-vector nil) 0) + (read-event))))) ;; Put yank-menu back as it was, if we changed it. (when saved-yank-menu (setq yank-menu (copy-sequence saved-yank-menu)) -- cgit v1.2.3 From 72f813fb5692a4b8ef0c57808941f0e97a588d7c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 11 Nov 2017 11:53:42 +0200 Subject: Fix desktop auto-save timer when linum-mode is used * lisp/desktop.el (desktop-read): Use toplevel value of window-configuration-change-hook when deciding whether desktop auto-saving is enabled. Suggested by Peter Neidhardt . (Bug#28945) --- lisp/desktop.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/desktop.el b/lisp/desktop.el index 2e53b15af38..c3c9da53b06 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -1240,7 +1240,13 @@ Using it may cause conflicts. Use it anyway? " owner))))) ;; disabled when loading the desktop fails with errors, ;; thus not overwriting the desktop with broken contents. (setq desktop-autosave-was-enabled - (memq 'desktop-auto-save-set-timer window-configuration-change-hook)) + (memq 'desktop-auto-save-set-timer + ;; Use the toplevel value of the hook, in case some + ;; feature makes window-configuration-change-hook + ;; buffer-local, and puts there stuff which + ;; doesn't include our timer. + (default-toplevel-value + 'window-configuration-change-hook))) (desktop-auto-save-disable) ;; Evaluate desktop buffer and remember when it was modified. (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name)))) -- cgit v1.2.3 From 603a0716a8824731a689d3b5144b55eed9ee4db4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 11 Nov 2017 13:48:37 +0200 Subject: Improve the documentation of M-n for entering file names * lisp/files.el (find-file, find-file-other-window) (find-file-other-frame): Mention file-name-at-point-functions in the doc string. Reported by Florian Weimer in http://lists.gnu.org/archive/html/emacs-devel/2017-11/msg00224.html. * doc/emacs/mini.texi (Minibuffer History): Document file-name-at-point-functions and its effect on M-n when typing file names in the minibuffer. * doc/emacs/files.texi (File Names): * doc/emacs/mini.texi (Minibuffer File): Add a cross-reference to "Minibuffer History", where special features of M-n regarding files are described. --- doc/emacs/files.texi | 3 +++ doc/emacs/mini.texi | 24 +++++++++++++++++++++--- lisp/files.el | 30 +++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 18f1c28571b..b11f588b466 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -63,6 +63,9 @@ completing up to a nonexistent file name, Emacs prints @samp{[Confirm]} and you must type a second @key{RET} to confirm. @xref{Completion Exit}, for details. +Minibuffer history commands offer some special features for reading +file names, see @ref{Minibuffer History}. + @cindex default directory @vindex default-directory @vindex insert-default-directory diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 83e7f3b7eb5..93f91420771 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -89,7 +89,10 @@ the default directory. If you now type @kbd{buffer.c} as input, that specifies the file @file{/u2/emacs/src/buffer.c}. @xref{File Names}, for information about the default directory. - You can specify the parent directory with @file{..}: + Alternative defaults for the file name you may want are available by +typing @kbd{M-n}, see @ref{Minibuffer History}. + + You can specify a file in the parent directory with @file{..}: @file{/a/b/../foo.el} is equivalent to @file{/a/foo.el}. Alternatively, you can use @kbd{M-@key{DEL}} to kill directory names backwards (@pxref{Words}). @@ -609,8 +612,6 @@ Move to a later item in the minibuffer history that matches @kindex M-p @r{(minibuffer history)} @kindex M-n @r{(minibuffer history)} -@kindex UP @r{(minibuffer history)} -@kindex DOWN @r{(minibuffer history)} @findex next-history-element @findex previous-history-element While in the minibuffer, @kbd{M-p} (@code{previous-history-element}) @@ -627,8 +628,25 @@ typed @kbd{M-p}), Emacs tries fetching from a list of default arguments: values that you are likely to enter. You can think of this as moving through the ``future history''. +@cindex future history for file names +@cindex minibuffer defaults for file names +@vindex file-name-at-point-functions + The ``future history'' for file names includes several possible +alternatives you may find useful, such as the file name or the URL at +point in the current buffer. The defaults put into the ``future +history'' in this case are controlled by the functions mentioned in +the value of the option @code{file-name-at-point-functions}. By +default, its value invokes the @code{ffap} package (@pxref{FFAP}), +which tries to guess the default file or URL from the text around +point. To disable this guessing, customize the option to a @code{nil} +value, then the ``future history'' of file names will include only the +file, if any, visited by the current buffer, and the default +directory. + @findex previous-line-or-history-element @findex next-line-or-history-element +@kindex UP @r{(minibuffer history)} +@kindex DOWN @r{(minibuffer history)} The arrow keys @kbd{@key{UP}} and @kbd{@key{DOWN}} work like @kbd{M-p} and @kbd{M-n}, but if the current history item is longer than a single line, they allow you to move to the previous or next diff --git a/lisp/files.el b/lisp/files.el index 9d46d5f85aa..b47411f206a 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1560,7 +1560,15 @@ Switch to a buffer visiting file FILENAME, creating one if none already exists. Interactively, the default if you just type RET is the current directory, but the visited file name is available through the minibuffer history: -type M-n to pull it into the minibuffer. +type \\[next-history-element] to pull it into the minibuffer. + +The first time \\[next-history-element] is used after Emacs prompts for +the file name, the result is affected by `file-name-at-point-functions', +which by default try to guess the file name by looking at point in the +current buffer. Customize the value of `file-name-at-point-functions' +or set it to nil, if you want only the visited file name and the +current directory to be available on first \\[next-history-element] +request. You can visit files on remote machines by specifying something like /ssh:SOME_REMOTE_MACHINE:FILE for the file name. You can @@ -1591,7 +1599,15 @@ an existing one. See the function `display-buffer'. Interactively, the default if you just type RET is the current directory, but the visited file name is available through the minibuffer history: -type M-n to pull it into the minibuffer. +type \\[next-history-element] to pull it into the minibuffer. + +The first time \\[next-history-element] is used after Emacs prompts for +the file name, the result is affected by `file-name-at-point-functions', +which by default try to guess the file name by looking at point in the +current buffer. Customize the value of `file-name-at-point-functions' +or set it to nil, if you want only the visited file name and the +current directory to be available on first \\[next-history-element] +request. Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." @@ -1615,7 +1631,15 @@ an existing one. See the function `display-buffer'. Interactively, the default if you just type RET is the current directory, but the visited file name is available through the minibuffer history: -type M-n to pull it into the minibuffer. +type \\[next-history-element] to pull it into the minibuffer. + +The first time \\[next-history-element] is used after Emacs prompts for +the file name, the result is affected by `file-name-at-point-functions', +which by default try to guess the file name by looking at point in the +current buffer. Customize the value of `file-name-at-point-functions' +or set it to nil, if you want only the visited file name and the +current directory to be available on first \\[next-history-element] +request. Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files." -- cgit v1.2.3 From d63c9a96f51fd4d723dc66a6cc0a8a0a04c8ce6c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 11 Nov 2017 10:25:20 -0500 Subject: * lisp/minibuffer.el: Install a workaround for bug#16274 * lisp/minibuffer.el (completion--nth-completion): Avoid signaling an error when `md` is applied to another table. --- lisp/minibuffer.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 26861de87b0..a4a8f5cb282 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -896,8 +896,15 @@ This overrides the defaults specified in `completion-category-defaults'." ;; than from completion-extra-properties) because it may apply only to some ;; part of the string (e.g. substitute-in-file-name). (let ((requote - (when (completion-metadata-get metadata 'completion--unquote-requote) - (cl-assert (functionp table)) + (when (and + (completion-metadata-get metadata 'completion--unquote-requote) + ;; Sometimes a table's metadata is used on another + ;; table (typically that other table is just a list taken + ;; from the output of `all-completions' or something equivalent, + ;; for progressive refinement). See bug#28898 and bug#16274. + ;; FIXME: Rather than do nothing, we should somehow call + ;; the original table, in that case! + (functionp table)) (let ((new (funcall table string point 'completion--unquote))) (setq string (pop new)) (setq table (pop new)) -- cgit v1.2.3 From 9533d76b0b5bfe2df1cccc55a92c2545b1de4e2b Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 25 Oct 2017 16:57:43 +0100 Subject: Keep Man sections in natural order (bug#28998) * lisp/man.el (Man-build-section-alist): Reverse sections. --- lisp/man.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp') diff --git a/lisp/man.el b/lisp/man.el index 7a892c6e88a..f7b1609c929 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1522,7 +1522,8 @@ The following key bindings are currently in effect in the buffer: (let ((section (match-string 1))) (unless (member section Man--sections) (push section Man--sections))) - (forward-line 1)))) + (forward-line 1))) + (setq Man--sections (nreverse Man--sections))) (defsubst Man-build-references-alist () "Build the list of references (in the SEE ALSO section)." -- cgit v1.2.3