commit fbe87d0f8f8878b30b1dfe74f7eb369b569bab6b (HEAD, refs/remotes/origin/master) Author: Dmitry Gutov Date: Fri Jan 18 06:38:12 2019 +0300 Rebase project-find-regexp on top of project-files * lisp/progmodes/project.el (project--files-in-directory): New function. (project-files, project-find-regexp): Use it. (project--dir-ignores): New function. (project--find-regexp-in): Remove. (project--process-file-region): New function. (project--find-regexp-in-files): New function. (project-find-regexp, project-or-external-find-regexp): Use it, and project-files as well. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index c16b2578eb..f795c36fa0 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -184,17 +184,30 @@ to find the list of ignores for each directory." (require 'xref) (cl-mapcan (lambda (dir) - (let ((command - (format "%s %s %s -type f -print0" - find-program - (shell-quote-argument - (expand-file-name dir)) - (xref--find-ignores-arguments - (project-ignores project dir) - (expand-file-name dir))))) - (split-string (shell-command-to-string command) "\0" t))) + (project--files-in-directory dir (project-ignores project dir))) (or dirs (project-roots project)))) +(defun project--files-in-directory (dir ignores &optional files) + (require 'find-dired) + (defvar find-name-arg) + (let ((command (format "%s %s %s -type f %s -print0" + find-program + dir + (xref--find-ignores-arguments + ignores + (expand-file-name dir)) + (if files + (concat (shell-quote-argument "(") + " " find-name-arg " " + (mapconcat + #'shell-quote-argument + (split-string files) + (concat " -o " find-name-arg " ")) + " " + (shell-quote-argument ")"))"") + ))) + (split-string (shell-command-to-string command) "\0" t))) + (defgroup project-vc nil "Project implementation using the VC package." :version "25.1" @@ -320,11 +333,26 @@ triggers completion when entering a pattern, including it requires quoting, e.g. `\\[quoted-insert]'." (interactive (list (project--read-regexp))) (let* ((pr (project-current t)) - (dirs (if current-prefix-arg - (list (read-directory-name "Base directory: " - nil default-directory t)) - (project-roots pr)))) - (project--find-regexp-in dirs regexp pr))) + (files + (if (not current-prefix-arg) + (project-files pr (project-roots pr)) + (let ((dir (read-directory-name "Base directory: " + nil default-directory t))) + (project--files-in-directory dir + (project--dir-ignores pr dir) + (grep-read-files regexp)))))) + (project--find-regexp-in-files regexp files))) + +(defun project--dir-ignores (project dir) + (let* ((roots (project-roots project)) + (root (cl-find dir roots :test #'file-in-directory-p))) + (when root + (let ((ignores (project-ignores project root))) + (if (file-equal-p root dir) + ignores + ;; FIXME: Update the "rooted" ignores to relate to DIR instead. + (cl-delete-if (lambda (str) (string-prefix-p "./" str)) + ignores)))))) ;;;###autoload (defun project-or-external-find-regexp (regexp) @@ -333,29 +361,76 @@ With \\[universal-argument] prefix, you can specify the file name pattern to search for." (interactive (list (project--read-regexp))) (let* ((pr (project-current t)) - (dirs (append - (project-roots pr) - (project-external-roots pr)))) - (project--find-regexp-in dirs regexp pr))) + (files + (project-files pr (append + (project-roots pr) + (project-external-roots pr))))) + (project--find-regexp-in-files regexp files))) + +(defun project--find-regexp-in-files (regexp files) + (pcase-let* + ((output (get-buffer-create " *project grep output*")) + (`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist)) + (status nil) + (hits nil) + (xrefs nil) + (command (format "xargs -0 grep %s -nHe %s" + (if (and case-fold-search + (isearch-no-upper-case-p regexp t)) + "-i" + "") + (shell-quote-argument (xref--regexp-to-extended regexp))))) + (with-current-buffer output + (erase-buffer) + (with-temp-buffer + (insert (mapconcat #'identity files "\0")) + (setq status + (project--process-file-region (point-min) + (point-max) + shell-file-name + output + nil + shell-command-switch + command))) + (goto-char (point-min)) + (when (and (/= (point-min) (point-max)) + (not (looking-at grep-re)) + ;; TODO: Show these matches as well somehow? + (not (looking-at "Binary file .* matches"))) + (user-error "Search failed with status %d: %s" status + (buffer-substring (point-min) (line-end-position)))) + (while (re-search-forward grep-re nil t) + (push (list (string-to-number (match-string line-group)) + (match-string file-group) + (buffer-substring-no-properties (point) (line-end-position))) + hits))) + (setq xrefs (xref--convert-hits (nreverse hits) regexp)) + (unless xrefs + (user-error "No matches for: %s" regexp)) + (xref--show-xrefs xrefs nil))) + +(defun project--process-file-region (start end program + &optional buffer display + &rest args) + ;; FIXME: This branching shouldn't be necessary, but + ;; call-process-region *is* measurably faster, even for a program + ;; doing some actual work (for a period of time). Even though + ;; call-process-region also creates a temp file internally + ;; (http://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00211.html). + (if (not (file-remote-p default-directory)) + (apply #'call-process-region + start end program nil buffer display args) + (let ((infile (make-temp-file "ppfr"))) + (unwind-protect + (progn + (write-region start end infile nil 'silent) + (apply #'process-file program infile buffer display args)) + (delete-file infile))))) (defun project--read-regexp () (let ((id (xref-backend-identifier-at-point (xref-find-backend)))) (read-regexp "Find regexp" (and id (regexp-quote id))))) -(defun project--find-regexp-in (dirs regexp project) - (require 'grep) - (let* ((files (if current-prefix-arg - (grep-read-files regexp) - "*")) - (xrefs (cl-mapcan - (lambda (dir) - (xref-collect-matches regexp files dir - (project-ignores project dir))) - dirs))) - (unless xrefs - (user-error "No matches for: %s" regexp)) - (xref--show-xrefs xrefs nil))) - ;;;###autoload (defun project-find-file () "Visit a file (with completion) in the current project's roots. commit afc8a41f4889b0b207bbd1c30fa9f310437b439e Author: Dmitry Gutov Date: Mon Jan 14 00:29:38 2019 +0300 ; Update the number diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index afb390468b..c16b2578eb 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -35,7 +35,7 @@ ;; Infrastructure: ;; ;; Function `project-current', to determine the current project -;; instance, and 3 (at the moment) generic functions that act on it. +;; instance, and 5 (at the moment) generic functions that act on it. ;; This list is to be extended in future versions. ;; ;; Utils: commit d8da0916fff16a3ef26cc1f929c262466e143268 Author: Dmitry Gutov Date: Mon Jan 14 00:16:19 2019 +0300 Make 'project-files' the "canonical" generic of the two * lisp/progmodes/project.el (project-files): Move the actual command building and invocation here. (project-file-completion-table): Delegate to 'project-files'. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 844744bf95..afb390468b 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -162,29 +162,14 @@ end it with `/'. DIR must be one of `project-roots' or DIRS is a list of absolute directories; it should be some subset of the project roots and external roots. -The default implementation uses `find-program'. PROJECT is used -to find the list of ignores for each directory." - ;; FIXME: Uniquely abbreviate the roots? - (require 'xref) - (let ((all-files - (cl-mapcan - (lambda (dir) - (let ((command - (format "%s %s %s -type f -print0" - find-program - (shell-quote-argument - (expand-file-name dir)) - (xref--find-ignores-arguments - (project-ignores project dir) - (expand-file-name dir))))) - (split-string (shell-command-to-string command) "\0" t))) - dirs))) +The default implementation delegates to `project-files'." + (let ((all-files (project-files project dirs))) (lambda (string pred action) (cond ((eq action 'metadata) - '(metadata . ((category . project-file)))) + '(metadata . ((category . project-file)))) (t - (complete-with-action action all-files string pred)))))) + (complete-with-action action all-files string pred)))))) (cl-defmethod project-roots ((project (head transient))) (list (cdr project))) @@ -192,14 +177,23 @@ to find the list of ignores for each directory." (cl-defgeneric project-files (project &optional dirs) "Return a list of files in directories DIRS in PROJECT. DIRS is a list of absolute directories; it should be some -subset of the project roots and external roots." - ;; This default implementation only works if project-file-completion-table - ;; returns a "flat" completion table. - ;; FIXME: Maybe we should do the reverse: implement the default - ;; `project-file-completion-table' on top of `project-files'. - (all-completions - "" (project-file-completion-table - project (or dirs (project-roots project))))) +subset of the project roots and external roots. + +The default implementation uses `find-program'. PROJECT is used +to find the list of ignores for each directory." + (require 'xref) + (cl-mapcan + (lambda (dir) + (let ((command + (format "%s %s %s -type f -print0" + find-program + (shell-quote-argument + (expand-file-name dir)) + (xref--find-ignores-arguments + (project-ignores project dir) + (expand-file-name dir))))) + (split-string (shell-command-to-string command) "\0" t))) + (or dirs (project-roots project)))) (defgroup project-vc nil "Project implementation using the VC package." commit e99a1241108433a63879a2430d55f2a1910d3c89 Author: Stefan Monnier Date: Thu Jan 17 18:25:00 2019 -0500 * lisp/textmodes/sgml-mode.el: Try and fix bug#33887. Remove redundant :group args. (sgml-syntax-propertize-rules): Speed up processing of most double quotes. diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 6c46efbbaa..e49144e290 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -46,8 +46,7 @@ (defcustom sgml-basic-offset 2 "Specifies the basic indentation level for `sgml-indent-line'." - :type 'integer - :group 'sgml) + :type 'integer) (defcustom sgml-attribute-offset 0 "Specifies a delta for attribute indentation in `sgml-indent-line'. @@ -65,16 +64,14 @@ When 2, attribute indentation looks like this: " :version "25.1" :type 'integer - :safe 'integerp - :group 'sgml) + :safe 'integerp) (defcustom sgml-xml-mode nil "When non-nil, tag insertion functions will be XML-compliant. It is set to be buffer-local when the file has a DOCTYPE or an XML declaration." :type 'boolean - :version "22.1" - :group 'sgml) + :version "22.1") (defvaralias 'sgml-transformation 'sgml-transformation-function) @@ -89,8 +86,7 @@ a DOCTYPE or an XML declaration." (and (derived-mode-p 'sgml-mode) (not sgml-xml-mode) (setq skeleton-transformation-function val)))) - (buffer-list))) - :group 'sgml) + (buffer-list)))) (put 'sgml-transformation-function 'variable-interactive "aTransformation function: ") @@ -98,7 +94,6 @@ a DOCTYPE or an XML declaration." (defcustom sgml-mode-hook nil "Hook run by command `sgml-mode'. `text-mode-hook' is run first." - :group 'sgml :type 'hook) ;; As long as Emacs's syntax can't be complemented with predicates to context @@ -211,8 +206,7 @@ This takes effect when first loading the `sgml-mode' library.") (defcustom sgml-name-8bit-mode nil "When non-nil, insert non-ASCII characters as named entities." - :type 'boolean - :group 'sgml) + :type 'boolean) (defvar sgml-char-names [nil nil nil nil nil nil nil nil @@ -282,8 +276,7 @@ Currently, only Latin-1 characters are supported.") The file name of current buffer file name will be appended to this, separated by a space." :type 'string - :version "21.1" - :group 'sgml) + :version "21.1") (defvar sgml-saved-validate-command nil "The command last used to validate in this buffer.") @@ -292,8 +285,7 @@ separated by a space." ;; so use a small distance here. (defcustom sgml-slash-distance 1000 "If non-nil, is the maximum distance to search for matching `/'." - :type '(choice (const nil) integer) - :group 'sgml) + :type '(choice (const nil) integer)) (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*") (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*") @@ -305,8 +297,7 @@ Any terminating `>' or `/' is not matched.") (defface sgml-namespace '((t (:inherit font-lock-builtin-face))) - "`sgml-mode' face used to highlight the namespace part of identifiers." - :group 'sgml) + "`sgml-mode' face used to highlight the namespace part of identifiers.") (defvar sgml-namespace-face 'sgml-namespace) ;; internal @@ -352,12 +343,21 @@ Any terminating `>' or `/' is not matched.") ("--[ \t\n]*\\(>\\)" (1 "> b")) ("\\(<\\)[?!]" (1 (prog1 "|>" (sgml-syntax-propertize-inside end)))) - ;; Double quotes outside of tags should not introduce strings. - ;; Be careful to call `syntax-ppss' on a position before the one we're - ;; going to change, so as not to need to flush the data we just computed. - ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) - (goto-char (match-end 0))) - (string-to-syntax "."))))))) + ;; Double quotes outside of tags should not introduce strings which end up + ;; hiding tags. We used to test every double quote and mark it as "." + ;; if it's outside of tags, but there are too many double quotes and + ;; the resulting number of calls to syntax-ppss made it too slow + ;; (bug#33887), so we're now careful to leave alone any pair + ;; of quotes that doesn't hold a < or > char, which is the vast majority. + ("\\(\"\\)[^\"<>]*[<>\"]" + (1 (unless (eq ?\" (char-before)) + ;; Be careful to call `syntax-ppss' on a position before the one + ;; we're going to change, so as not to need to flush the data we + ;; just computed. + (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) + (goto-char (1- (match-end 0)))) + (string-to-syntax "."))))) + ))) (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." @@ -421,8 +421,7 @@ The attribute alist is made up as ATTRIBUTERULE is a list of optionally t (no value when no input) followed by an optional alist of possible values." :type '(repeat (cons (string :tag "Tag Name") - (repeat :tag "Tag Rule" sexp))) - :group 'sgml) + (repeat :tag "Tag Rule" sexp)))) (put 'sgml-tag-alist 'risky-local-variable t) (defcustom sgml-tag-help @@ -434,8 +433,7 @@ an optional alist of possible values." ("!entity" . "Entity (macro) declaration")) "Alist of tag name and short description." :type '(repeat (cons (string :tag "Tag Name") - (string :tag "Description"))) - :group 'sgml) + (string :tag "Description")))) (defvar sgml-empty-tags nil "List of tags whose !ELEMENT definition says EMPTY.") @@ -461,7 +459,7 @@ an optional alist of possible values." nil t) (string-match "X\\(HT\\)?ML" (match-string 3)))))) -(defvar v2) ; free for skeleton +(with-no-warnings (defvar v2)) ; free for skeleton (defun sgml-comment-indent-new-line (&optional soft) (let ((comment-start "-- ") @@ -1722,7 +1720,6 @@ Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)." (defcustom html-mode-hook nil "Hook run by command `html-mode'. `text-mode-hook' and `sgml-mode-hook' are run first." - :group 'sgml :type 'hook :options '(html-autoview-mode)) @@ -2381,10 +2378,9 @@ HTML Autoview mode is a buffer-local minor mode for use with `html-mode'. If enabled, saving the file automatically runs `browse-url-of-buffer' to view it." nil nil nil - :group 'sgml (if html-autoview-mode - (add-hook 'after-save-hook 'browse-url-of-buffer nil t) - (remove-hook 'after-save-hook 'browse-url-of-buffer t))) + (add-hook 'after-save-hook #'browse-url-of-buffer nil t) + (remove-hook 'after-save-hook #'browse-url-of-buffer t))) (define-skeleton html-href-anchor commit be505726b68d407a44fdcd9c7ac1ef722398532d Author: João Távora Date: Thu Jan 17 18:47:00 2019 +0000 Fix electric-pair-tests by disabling bug#33794's fix with a variable The variable c--disable-fix-of-bug-33794, which should be removed in the short term in favor of a permanent solution, is introduced. It is bound to nil by default. This means that breakage is still happening in actual c-mode and c++-mode usage, though the tests no longer show it. To get around this breakage, put (setq c--disable-fix-of-bug-33794 t) In your init file. Evidently, you will lose the fix for bug#33794, but that only affects a small corner case of c-toggle-auto-newline, which is not turned on by default. See https://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00360.html for more information. * lisp/progmodes/cc-cmds.el (c--disable-fix-of-bug-33794): New variable. (c--with-post-self-insert-hook-maybe): New macro. (c-electric-pound, c-electric-brace, c-electric-slash) (c-electric-star, c-electric-semi&comma, c-electric-colon) (c-electric-lt-gt, c-electric-paren): Use it. (c-electric-paren, c-electric-brace): Check c--disable-fix-of-bug-33794. * test/lisp/electric-tests.el (c--disable-fix-of-bug-33794): Forward declare. (electric-pair-test-for) (electric-layout-int-main-kernel-style) (electric-modes-in-c-mode-with-self-insert-command): Use it. diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 78677fefad..6b0d961766 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -485,6 +485,20 @@ function to control that." (c-hungry-delete-forward) (c-hungry-delete-backwards))) +(defvar c--disable-fix-of-bug-33794 nil + "If non-nil disable alans controversional fix of 33794. +This fix breaks most features of `electric-pair-mode' by +incompletely reimplementing in in this mode.") + +(defmacro c--with-post-self-insert-hook-maybe (&rest body) + `(let ((post-self-insert-hook + (if c--disable-fix-of-bug-33794 + post-self-insert-hook + ;; Acording to AM: Disable random functionality to get + ;; defined functionality from `self-insert-command' + nil))) + ,@body)) + (defun c-electric-pound (arg) "Insert a \"#\". If `c-electric-flag' is set, handle it specially according to the variable @@ -504,7 +518,7 @@ inside a literal or a macro, nothing special happens." (eq (char-before) ?\\)))) (c-in-literal))) ;; do nothing special - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) ;; place the pound character at the left edge (let ((pos (- (point-max) (point))) @@ -857,36 +871,38 @@ settings of `c-cleanup-list' are done." ;; Insert the brace. Note that expand-abbrev might reindent ;; the line here if there's a preceding "else" or something. - (let (post-self-insert-hook) ; the only way to get defined functionality - ; from `self-insert-command'. - (self-insert-command (prefix-numeric-value arg))) + (c--with-post-self-insert-hook-maybe + (self-insert-command (prefix-numeric-value arg))) ;; Emulate `electric-pair-mode'. - (when (and (boundp 'electric-pair-mode) - electric-pair-mode) - (let ((size (buffer-size)) - (c-in-electric-pair-functionality t) - post-self-insert-hook) - (electric-pair-post-self-insert-function) - (setq got-pair-} (and at-eol - (eq (c-last-command-char) ?{) - (eq (char-after) ?})) - electric-pair-deletion (< (buffer-size) size)))) - - ;; Perform any required CC Mode electric actions. - (cond - ((or literal arg (not c-electric-flag) active-region)) - ((not at-eol) - (c-indent-line)) - (electric-pair-deletion - (c-indent-line) - (c-do-brace-electrics 'ignore nil)) - (t (c-do-brace-electrics nil nil) - (when got-pair-} - (save-excursion - (forward-char) - (c-do-brace-electrics 'assume 'ignore)) - (c-indent-line)))) + (unless c--disable-fix-of-bug-33794 + (when (and (boundp 'electric-pair-mode) + electric-pair-mode) + (let ((size (buffer-size)) + (c-in-electric-pair-functionality t) + post-self-insert-hook) + (electric-pair-post-self-insert-function) + (setq got-pair-} (and at-eol + (eq (c-last-command-char) ?{) + (eq (char-after) ?})) + electric-pair-deletion (< (buffer-size) size)))) + + ;; Perform any required CC Mode electric actions. + (cond + ((or literal arg (not c-electric-flag) active-region)) + ((not at-eol) + (c-indent-line)) + (electric-pair-deletion + (c-indent-line) + (c-do-brace-electrics 'ignore nil)) + (t (c-do-brace-electrics nil nil) + (when got-pair-} + (save-excursion + (forward-char) + (c-do-brace-electrics 'assume 'ignore)) + (c-indent-line))))) + + ;; blink the paren (and (eq (c-last-command-char) ?\}) @@ -944,7 +960,7 @@ is inhibited." c-electric-flag (eq (c-last-command-char) ?/) (eq (char-before) (if literal ?* ?/)))) - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) (if indentp (indent-according-to-mode)))) @@ -958,7 +974,7 @@ supplied, point is inside a literal, or `c-syntactic-indentation' is nil, this indentation is inhibited." (interactive "*P") - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) ;; if we are in a literal, or if arg is given do not reindent the ;; current line, unless this star introduces a comment-only line. @@ -1006,7 +1022,7 @@ settings of `c-cleanup-list'." (setq lim (c-most-enclosing-brace (c-parse-state)) literal (c-in-literal lim))) - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) (if (and c-electric-flag (not literal) (not arg)) @@ -1076,7 +1092,7 @@ reindented unless `c-syntactic-indentation' is nil. newlines is-scope-op ;; shut this up (c-echo-syntactic-information-p nil)) - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) ;; Any electric action? (if (and c-electric-flag (not literal) (not arg)) @@ -1170,7 +1186,7 @@ numeric argument is supplied, or the point is inside a literal." (let ((c-echo-syntactic-information-p nil) final-pos found-delim case-fold-search) - (let (post-self-insert-hook) ; Disable random functionality. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) (setq final-pos (point)) @@ -1236,8 +1252,7 @@ newline cleanups are done if appropriate; see the variable `c-cleanup-list'." ;; shut this up (c-echo-syntactic-information-p nil) case-fold-search) - (let (post-self-insert-hook) ; The only way to get defined functionality - ; from `self-insert-command'. + (c--with-post-self-insert-hook-maybe (self-insert-command (prefix-numeric-value arg))) (if (and (not arg) (not literal)) @@ -1288,10 +1303,11 @@ newline cleanups are done if appropriate; see the variable `c-cleanup-list'." (insert-and-inherit "} catch ("))) ;; Apply `electric-pair-mode' stuff. - (when (and (boundp 'electric-pair-mode) - electric-pair-mode) - (let (post-self-insert-hook) - (electric-pair-post-self-insert-function))) + (unless c--disable-fix-of-bug-33794 + (when (and (boundp 'electric-pair-mode) + electric-pair-mode) + (let (post-self-insert-hook) + (electric-pair-post-self-insert-function)))) ;; Check for clean-ups at function calls. These two DON'T need ;; `c-electric-flag' or `c-syntactic-indentation' set. diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 5a4b20ed04..b55d889f0b 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -47,10 +47,14 @@ (declare (indent defun) (debug t)) `(call-with-saved-electric-modes #'(lambda () ,@body))) +;; Defined in lisp/progmodes/cc-cmds.el +(defvar c--disable-fix-of-bug-33794 t) + (defun electric-pair-test-for (fixture where char expected-string expected-point mode bindings fixture-fn) (with-temp-buffer (funcall mode) + (setq-local c--disable-fix-of-bug-33794 t) (insert fixture) (save-electric-modes (let ((last-command-event char) @@ -821,6 +825,7 @@ baz\"\"" (electric-layout-local-mode 1) (electric-pair-local-mode 1) (electric-indent-local-mode 1) + (setq-local c--disable-fix-of-bug-33794 t) (setq-local electric-layout-rules '((?\{ . (after-stay after)))) (insert "int main () ") @@ -834,6 +839,7 @@ baz\"\"" (electric-layout-local-mode 1) (electric-pair-local-mode 1) (electric-indent-local-mode 1) + (setq-local c--disable-fix-of-bug-33794 t) (setq-local electric-layout-rules '((?\{ . (before after-stay after)))) (insert "int main () ") commit 4bdc03746915c36313b33b6998b855eef514cdd1 Author: João Távora Date: Thu Jan 17 18:08:01 2019 +0000 Revert "Temporarily comment out CC Mode from tests..." This reverts commit 54f297904e0c641fcfd81f16e9a87177124a27be. diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 86d0daa605..5a4b20ed04 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -157,8 +157,7 @@ The buffer's contents should %s: expected-string expected-point bindings - (modes '(quote (ruby-mode ;; c++-mode - ))) + (modes '(quote (ruby-mode c++-mode))) (test-in-comments t) (test-in-strings t) (test-in-code t) @@ -397,10 +396,10 @@ baz\"\"" ;; mode will sort this out eventually, using some new e-p-m machinery. ;; See ;; https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00535.html -;; (setf -;; (ert-test-expected-result-type -;; (ert-get-test 'electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings)) -;; :failed) +(setf + (ert-test-expected-result-type + (ert-get-test 'electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings)) + :failed) (define-electric-pair-test whitespace-chomping-dont-cross-comments " ( \n\t\t\n ) " "--)------" :expected-string " () \n\t\t\n ) " @@ -816,34 +815,31 @@ baz\"\"" ;;; tests for `electric-layout-mode' -;; Tests commented out, since C Mode does not use -;; electric-layout-mode. 2019-01-17, ACM - -;; (ert-deftest electric-layout-int-main-kernel-style () -;; (ert-with-test-buffer () -;; (c-mode) -;; (electric-layout-local-mode 1) -;; (electric-pair-local-mode 1) -;; (electric-indent-local-mode 1) -;; (setq-local electric-layout-rules -;; '((?\{ . (after-stay after)))) -;; (insert "int main () ") -;; (let ((last-command-event ?\{)) -;; (call-interactively (key-binding `[,last-command-event]))) -;; (should (equal (buffer-string) "int main () {\n \n}")))) - -;; (ert-deftest electric-layout-int-main-allman-style () -;; (ert-with-test-buffer () -;; (c-mode) -;; (electric-layout-local-mode 1) -;; (electric-pair-local-mode 1) -;; (electric-indent-local-mode 1) -;; (setq-local electric-layout-rules -;; '((?\{ . (before after-stay after)))) -;; (insert "int main () ") -;; (let ((last-command-event ?\{)) -;; (call-interactively (key-binding `[,last-command-event]))) -;; (should (equal (buffer-string) "int main ()\n{\n \n}")))) +(ert-deftest electric-layout-int-main-kernel-style () + (ert-with-test-buffer () + (c-mode) + (electric-layout-local-mode 1) + (electric-pair-local-mode 1) + (electric-indent-local-mode 1) + (setq-local electric-layout-rules + '((?\{ . (after-stay after)))) + (insert "int main () ") + (let ((last-command-event ?\{)) + (call-interactively (key-binding `[,last-command-event]))) + (should (equal (buffer-string) "int main () {\n \n}")))) + +(ert-deftest electric-layout-int-main-allman-style () + (ert-with-test-buffer () + (c-mode) + (electric-layout-local-mode 1) + (electric-pair-local-mode 1) + (electric-indent-local-mode 1) + (setq-local electric-layout-rules + '((?\{ . (before after-stay after)))) + (insert "int main () ") + (let ((last-command-event ?\{)) + (call-interactively (key-binding `[,last-command-event]))) + (should (equal (buffer-string) "int main ()\n{\n \n}")))) (define-derived-mode plainer-c-mode c-mode "pC" "A plainer/saner C-mode with no internal electric machinery." commit e5663bea40f9da9860ea545198c6786cd884be0a Author: Martin Rudalics Date: Thu Jan 17 19:07:47 2019 +0100 Fix wording in Window Hooks section of Elisp manual * doc/lispref/windows.texi (Window Hooks): Fix wording in description of window change functions. Suggested by Robert Pluim . diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index afb81e6874..6ac7aa6728 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -6085,13 +6085,15 @@ functions that take one argument. Functions specified buffer-locally are called for any window showing the corresponding buffer if that window has been added or assigned -another buffer, total or body size since the last time window change -functions were run. In this case the window is passed as argument. +another buffer or changed its total or body size since the last time +window change functions were run. In this case the window is passed +as argument. Functions specified by the default value are called for a frame if at least one window on that frame has been added or assigned another -buffer, total or body size since the last time window change functions -were run. In this case the frame is passed as argument. +buffer or changed its total or body size since the last time window +change functions were run. In this case the frame is passed as +argument. @end defvar @cindex window selection change @@ -6128,17 +6130,17 @@ functions that take one argument. Functions specified buffer-locally are called for any window showing the corresponding buffer if that window has been added or assigned -another buffer, total or body size or has been selected or deselected -(among all windows or among all windows on its frame) since the last -time window change functions were run. In this case the window is -passed as argument. +another buffer, changed its total or body size or has been selected or +deselected (among all windows or among all windows on its frame) since +the last time window change functions were run. In this case the +window is passed as argument. Functions specified by the default value are called for a frame if at least one window on that frame has been added, deleted or assigned -another buffer, total or body size or that frame has been selected or -deselected or the frame's selected window has changed since the last -time window change functions were run. In this case the frame is -passed as argument. +another buffer, changed its total or body size or that frame has been +selected or deselected or the frame's selected window has changed +since the last time window change functions were run. In this case +the frame is passed as argument. @end defvar @cindex window configuration change @@ -6154,25 +6156,26 @@ should be a list of functions that take no argument. Functions specified buffer-locally are called for any window showing the corresponding buffer if at least one window on that frame has been -added, deleted or assigned another buffer, total or body size since -the last time window change functions were run. Each call is -performed with the window showing the buffer temporarily selected and -its buffer current. +added, deleted or assigned another buffer or changed its total or +body size since the last time window change functions were run. Each +call is performed with the window showing the buffer temporarily +selected and its buffer current. Functions specified by the default value are called for each frame if at least one window on that frame has been added, deleted or assigned -another buffer, total or body size since the last time window change -functions were run. Each call is performed with the frame temporarily -selected and the selected window's buffer current. +another buffer or changed its total or body size since the last time +window change functions were run. Each call is performed with the +frame temporarily selected and the selected window's buffer current. @end defvar Window change functions are called at the end of redisplay for each frame as follows: First, any buffer-local window buffer change -function, window size change function and selected window change -functions are called in this order. Next, the default values for -these functions are called in the same order. Then any buffer-local -window configuration change functions are called followed by functions -specified by the default value of those functions. +function, window size change function, selected window change and +window state change functions are called in this order. Next, the +default values for these functions are called in the same order. Then +any buffer-local window configuration change functions are called +followed by functions specified by the default value of those +functions. Window change functions are run for a specific frame only if a corresponding change was registered for that frame earlier. Such commit 03b8903ee7fffc75085600899c992829a49d4442 Author: Alan Third Date: Tue Jan 15 16:38:34 2019 +0000 Be more specific with XRender bit-depths (bug#34051) * src/image.c (x_create_x_image_and_pixmap): Fail gracefully if a bit depth is requested that XRender doesn't support. diff --git a/src/image.c b/src/image.c index 2f0b63ca89..e4b097588a 100644 --- a/src/image.c +++ b/src/image.c @@ -2179,15 +2179,29 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth, int event_basep, error_basep; if (picture && XRenderQueryExtension (display, &event_basep, &error_basep)) { - XRenderPictFormat *format; - XRenderPictureAttributes attr; - - /* FIXME: Do we need to handle all possible bit depths? */ - format = XRenderFindStandardFormat (display, - depth > 24 ? PictStandardARGB32 - : depth > 8 ? PictStandardRGB24 - : PictStandardA8); - *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr); + if (depth == 32 || depth == 24 || depth == 8) + { + XRenderPictFormat *format; + XRenderPictureAttributes attr; + + /* FIXME: Do we need to handle all possible bit depths? + XRenderFindStandardFormat supports PictStandardARGB32, + PictStandardRGB24, PictStandardA8, PictStandardA4, + PictStandardA1, and PictStandardNUM (what is this?!). + + XRenderFindFormat may support more, but I don't + understand the documentation. */ + format = XRenderFindStandardFormat (display, + depth == 32 ? PictStandardARGB32 + : depth == 24 ? PictStandardRGB24 + : PictStandardA8); + *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr); + } + else + { + image_error ("Specified image bit depth is not supported by XRender"); + *picture = NULL; + } } # endif commit 5a6df06494f9ba6df53af82cfdf81f1d3708edc3 Author: João Távora Date: Tue Jan 15 12:10:23 2019 +0000 Simplify ignored extensions filtering in Icomplete (bug#34070) * lisp/icomplete.el: Use lexical binding. (icomplete-completions): Use minibuffer-completion-predicate to filter out completion-ignored-extensions. diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 8bed46cb3b..6d77c0649a 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -1,4 +1,4 @@ -;;; icomplete.el --- minibuffer completion incremental feedback +;;; icomplete.el --- minibuffer completion incremental feedback -*- lexical-binding: t -*- ;; Copyright (C) 1992-1994, 1997, 1999, 2001-2019 Free Software ;; Foundation, Inc. @@ -368,8 +368,21 @@ If there are multiple possibilities, `icomplete-separator' separates them. The displays for unambiguous matches have ` [Matched]' appended \(whether complete or not), or ` [No matches]', if no eligible matches exist." - (let* ((minibuffer-completion-table candidates) - (minibuffer-completion-predicate predicate) + (let* ((ignored-extension-re + (and minibuffer-completing-file-name + icomplete-with-completion-tables + completion-ignored-extensions + (concat "\\(?:\\`\\.\\./\\|" + (regexp-opt completion-ignored-extensions) + "\\)\\'"))) + (minibuffer-completion-table candidates) + (minibuffer-completion-predicate + (if ignored-extension-re + (lambda (cand) + (and (not (string-match ignored-extension-re cand)) + (or (null predicate) + (funcall predicate cand)))) + predicate)) (md (completion--field-metadata (icomplete--field-beg))) (comps (completion-all-sorted-completions (icomplete--field-beg) (icomplete--field-end))) @@ -380,11 +393,8 @@ matches exist." ;; `concat'/`mapconcat' is the slow part. (if (not (consp comps)) (progn ;;(debug (format "Candidates=%S field=%S" candidates name)) - (format " %sNo matches%s" open-bracket close-bracket)) + (format " %sNo matches%s" open-bracket close-bracket)) (if last (setcdr last nil)) - (when (and minibuffer-completing-file-name - icomplete-with-completion-tables) - (setq comps (completion-pcm--filename-try-filter comps))) (let* ((most-try (if (and base-size (> base-size 0)) (completion-try-completion @@ -470,11 +480,11 @@ matches exist." (if prefix-len (substring (car comps) prefix-len) (car comps)) comps (cdr comps)) (setq prospects-len - (+ (string-width comp) - (string-width icomplete-separator) - prospects-len)) - (if (< prospects-len prospects-max) - (push comp prospects) + (+ (string-width comp) + (string-width icomplete-separator) + prospects-len)) + (if (< prospects-len prospects-max) + (push comp prospects) (setq limit t)))) (setq prospects (nreverse prospects)) ;; Decorate first of the prospects. commit 7560ef7de925b56f367df168befc9b748b6237c1 Author: João Távora Date: Thu Jan 17 15:11:21 2019 +0000 Revert "Fix icomplete's cycling when filename filtering kicks in" This reverts commit cdb082322d4209c5104bc1a98b21bf3dd75e8f17, which was a fix for bug#34070. A much better fix to be added soon. diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 82e2728487..8bed46cb3b 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -162,9 +162,6 @@ the default otherwise." (minibuffer-force-complete-and-exit) (minibuffer-complete-and-exit))) -(defvar icomplete--filtered-completions nil - "If non-nil completions as filtered by `icomplete-completions'") - (defun icomplete-forward-completions () "Step forward completions by one entry. Second entry becomes the first and can be selected with @@ -172,8 +169,7 @@ Second entry becomes the first and can be selected with (interactive) (let* ((beg (icomplete--field-beg)) (end (icomplete--field-end)) - (comps (or icomplete--filtered-completions - (completion-all-sorted-completions beg end))) + (comps (completion-all-sorted-completions beg end)) (last (last comps))) (when comps (setcdr last (cons (car comps) (cdr last))) @@ -186,8 +182,7 @@ Last entry becomes the first and can be selected with (interactive) (let* ((beg (icomplete--field-beg)) (end (icomplete--field-end)) - (comps (or icomplete--filtered-completions - (completion-all-sorted-completions beg end))) + (comps (completion-all-sorted-completions beg end)) (last-but-one (last comps 2)) (last (cdr last-but-one))) (when (consp last) ; At least two elements in comps @@ -387,11 +382,9 @@ matches exist." (progn ;;(debug (format "Candidates=%S field=%S" candidates name)) (format " %sNo matches%s" open-bracket close-bracket)) (if last (setcdr last nil)) - (if (and minibuffer-completing-file-name - icomplete-with-completion-tables) - (setq comps (completion-pcm--filename-try-filter comps) - icomplete--filtered-completions comps) - (setq icomplete--filtered-completions nil)) + (when (and minibuffer-completing-file-name + icomplete-with-completion-tables) + (setq comps (completion-pcm--filename-try-filter comps))) (let* ((most-try (if (and base-size (> base-size 0)) (completion-try-completion commit 80cbfb61c5a562d51197d6f3068fa5f4cda432b0 Author: João Távora Date: Thu Jan 17 14:38:44 2019 +0000 Fix flymake-proc--delete-temp-directory if temp dir ends in slash Fixes: bug#34074 Reported by 林宝龙 . * lisp/progmodes/flymake-proc.el (flymake-proc--delete-temp-directory): Use directory-file-name. diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el index 7cdbb266fe..2d9dd047a3 100644 --- a/lisp/progmodes/flymake-proc.el +++ b/lisp/progmodes/flymake-proc.el @@ -887,7 +887,7 @@ can also be executed interactively independently of (defun flymake-proc--delete-temp-directory (dir-name) "Attempt to delete temp dir created by `flymake-proc-create-temp-with-folder-structure', do not fail on error." (let* ((temp-dir temporary-file-directory) - (suffix (substring dir-name (1+ (length temp-dir))))) + (suffix (substring dir-name (1+ (length (directory-file-name temp-dir)))))) (while (> (length suffix) 0) (setq suffix (directory-file-name suffix)) commit 54f297904e0c641fcfd81f16e9a87177124a27be Author: Alan Mackenzie Date: Thu Jan 17 12:51:40 2019 +0000 Temporarily comment out CC Mode from tests which are incompatible with it. * tests/electric-tests (electric-pair-test-for): comment out c++-mode from the list of modes to be used in tests. (electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings) (ert-deftest electric-layout-int-main-kernel-style) (ert-deftest electric-layout-int-main-allman-style): Comment out. diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 5a4b20ed04..86d0daa605 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -157,7 +157,8 @@ The buffer's contents should %s: expected-string expected-point bindings - (modes '(quote (ruby-mode c++-mode))) + (modes '(quote (ruby-mode ;; c++-mode + ))) (test-in-comments t) (test-in-strings t) (test-in-code t) @@ -396,10 +397,10 @@ baz\"\"" ;; mode will sort this out eventually, using some new e-p-m machinery. ;; See ;; https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00535.html -(setf - (ert-test-expected-result-type - (ert-get-test 'electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings)) - :failed) +;; (setf +;; (ert-test-expected-result-type +;; (ert-get-test 'electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings)) +;; :failed) (define-electric-pair-test whitespace-chomping-dont-cross-comments " ( \n\t\t\n ) " "--)------" :expected-string " () \n\t\t\n ) " @@ -815,31 +816,34 @@ baz\"\"" ;;; tests for `electric-layout-mode' -(ert-deftest electric-layout-int-main-kernel-style () - (ert-with-test-buffer () - (c-mode) - (electric-layout-local-mode 1) - (electric-pair-local-mode 1) - (electric-indent-local-mode 1) - (setq-local electric-layout-rules - '((?\{ . (after-stay after)))) - (insert "int main () ") - (let ((last-command-event ?\{)) - (call-interactively (key-binding `[,last-command-event]))) - (should (equal (buffer-string) "int main () {\n \n}")))) - -(ert-deftest electric-layout-int-main-allman-style () - (ert-with-test-buffer () - (c-mode) - (electric-layout-local-mode 1) - (electric-pair-local-mode 1) - (electric-indent-local-mode 1) - (setq-local electric-layout-rules - '((?\{ . (before after-stay after)))) - (insert "int main () ") - (let ((last-command-event ?\{)) - (call-interactively (key-binding `[,last-command-event]))) - (should (equal (buffer-string) "int main ()\n{\n \n}")))) +;; Tests commented out, since C Mode does not use +;; electric-layout-mode. 2019-01-17, ACM + +;; (ert-deftest electric-layout-int-main-kernel-style () +;; (ert-with-test-buffer () +;; (c-mode) +;; (electric-layout-local-mode 1) +;; (electric-pair-local-mode 1) +;; (electric-indent-local-mode 1) +;; (setq-local electric-layout-rules +;; '((?\{ . (after-stay after)))) +;; (insert "int main () ") +;; (let ((last-command-event ?\{)) +;; (call-interactively (key-binding `[,last-command-event]))) +;; (should (equal (buffer-string) "int main () {\n \n}")))) + +;; (ert-deftest electric-layout-int-main-allman-style () +;; (ert-with-test-buffer () +;; (c-mode) +;; (electric-layout-local-mode 1) +;; (electric-pair-local-mode 1) +;; (electric-indent-local-mode 1) +;; (setq-local electric-layout-rules +;; '((?\{ . (before after-stay after)))) +;; (insert "int main () ") +;; (let ((last-command-event ?\{)) +;; (call-interactively (key-binding `[,last-command-event]))) +;; (should (equal (buffer-string) "int main ()\n{\n \n}")))) (define-derived-mode plainer-c-mode c-mode "pC" "A plainer/saner C-mode with no internal electric machinery." commit 8ca414de0eb0b87f4c9a8d301cc45ec51312dace Author: Glenn Morris Date: Thu Jan 17 07:19:45 2019 -0500 Fix --enable-profiling builds (bug#34099) * src/profiler.c (syms_of_profiler_for_pdumper): Only set cpu_log if CPU profiling is enabled. diff --git a/src/profiler.c b/src/profiler.c index a98d967b2a..15a0eef0d3 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -627,12 +627,16 @@ syms_of_profiler_for_pdumper (void) { if (dumped_with_pdumper_p ()) { +#ifdef PROFILER_CPU_SUPPORT cpu_log = Qnil; +#endif memory_log = Qnil; } else { +#ifdef PROFILER_CPU_SUPPORT eassert (NILP (cpu_log)); +#endif eassert (NILP (memory_log)); }