diff options
Diffstat (limited to 'lisp/progmodes')
34 files changed, 496 insertions, 396 deletions
diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index a78c57c2053..921a904191c 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -69,7 +69,7 @@ so that it is considered safe, see `enable-local-variables'.") (get s 'bug-reference-url-format))))) (defcustom bug-reference-bug-regexp - "\\([Bb]ug ?#\\|[Pp]atch ?#\\|RFE ?#\\|PR [a-z-+]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)" + "\\([Bb]ug ?#?\\|[Pp]atch ?#\\|RFE ?#\\|PR [a-z-+]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)" "Regular expression matching bug references. The second subexpression should match the bug reference (usually a number)." :type 'string diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el index 077a18cc597..19a95aad676 100644 --- a/lisp/progmodes/cc-awk.el +++ b/lisp/progmodes/cc-awk.el @@ -72,7 +72,7 @@ (modify-syntax-entry ?\# "< " st) ;; / can delimit regexes or be a division operator. By default we assume ;; that it is a division sign, and fix the regexp operator cases with - ;; `font-lock-syntactic-keywords'. + ;; `c-awk-set-syntax-table-properties'. (modify-syntax-entry ?/ "." st) ; ACM 2002/4/27. (modify-syntax-entry ?* "." st) (modify-syntax-entry ?+ "." st) @@ -785,13 +785,16 @@ ;; Scan the buffer text between point and LIM, setting (and clearing) the ;; syntax-table property where necessary. ;; -;; This function is designed to be called as the FUNCTION in a MATCHER in -;; font-lock-syntactic-keywords, and it always returns NIL (to inhibit -;; repeated calls from font-lock: See elisp info page "Search-based -;; Fontification"). It also gets called, with a bit of glue, from -;; after-change-functions when font-lock isn't active. Point is left -;; "undefined" after this function exits. THE BUFFER SHOULD HAVE BEEN -;; WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE. +;; This function is designed to be called as the FUNCTION in a MATCHER +;; in font-lock-syntactic-keywords, and it always returns NIL (to +;; inhibit repeated calls from font-lock: See elisp info page +;; "Search-based Fontification"). (2015-11-24: CC Mode doesn't use +;; `font-lock-syntactic-keywords' and hasn't done for a very long +;; time, if ever. ACM.) This function gets called, with a bit of +;; glue, from after-change-functions whether or not font-lock is +;; active. Point is left "undefined" after this function exits. THE +;; BUFFER SHOULD HAVE BEEN WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED +;; BEFORE CALLING THIS ROUTINE. ;; ;; We need to set/clear the syntax-table property on: ;; (i) / - It is set to "string" on a / which is the opening or closing diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el index 81b7a822b82..d3b4db74c16 100644 --- a/lisp/progmodes/cc-bytecomp.el +++ b/lisp/progmodes/cc-bytecomp.el @@ -252,6 +252,11 @@ perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere")) (cc-bytecomp-debug-msg "cc-bytecomp-restore-environment: Done")))) +(defun cc-bytecomp-load (cc-part) + ;; A dummy function which will immediately be overwritten by the + ;; following at load time. This should suppress the byte compiler + ;; error that the function is "not known to be defined". +) (eval ;; This eval is to avoid byte compilation of the function below. ;; There's some bug in XEmacs 21.4.6 that can cause it to dump core @@ -284,9 +289,6 @@ perhaps a `cc-bytecomp-restore-environment' is forgotten somewhere")) (cc-bytecomp-setup-environment) t)))) -(defvar cc-bytecomp-noruntime-functions nil - "Saved value of `byte-compile-noruntime-functions'.") - (defmacro cc-require (cc-part) "Force loading of the corresponding .el file in the current directory during compilation, but compile in a `require'. Don't use within @@ -296,19 +298,37 @@ Having cyclic cc-require's will result in infinite recursion. That's somewhat intentional." `(progn (eval-when-compile - (if (boundp 'byte-compile-noruntime-functions) ; in case load uncompiled - (setq cc-bytecomp-noruntime-functions - byte-compile-noruntime-functions)) (cc-bytecomp-load (symbol-name ,cc-part))) - ;; Hack to suppress spurious "might not be defined at runtime" warnings. - ;; The basic issue is that - ;; (eval-when-compile (require 'foo)) - ;; (require 'foo) - ;; produces bogus noruntime warnings about functions from foo. - (eval-when-compile - (setq byte-compile-noruntime-functions cc-bytecomp-noruntime-functions)) (require ,cc-part))) +(defmacro cc-conditional-require (cc-part condition) + "If the CONDITION is satisfied at compile time, (i) force the +file CC-PART.el in the current directory to be loaded at compile +time, (ii) generate code to load the file at load time. + +CC-PART will normally be a quoted name such as 'cc-fix. +CONDITION should not be quoted." + (if (eval condition) + (progn + (cc-bytecomp-load (symbol-name (eval cc-part))) + `(require ,cc-part)) + '(progn))) + +(defmacro cc-conditional-require-after-load (cc-part file condition) + "If the CONDITION is satisfied at compile time, (i) force the +file CC-PART.el in the current directory to be loaded at compile +time, (ii) generate an `eval-after-load' form to load CC-PART.el +after the loading of FILE. + +CC-PART will normally be a quoted name such as 'cc-fix. FILE +should be a string. CONDITION should not be quoted." + (if (eval condition) + (progn + (cc-bytecomp-load (symbol-name (eval cc-part))) + `(eval-after-load ,file + '(require ,cc-part))) + '(progn))) + (defmacro cc-provide (feature) "A replacement for the `provide' form that restores the environment after the compilation. Don't use within `eval-when-compile'." diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 1b6108ef0b2..8eed4b1b86e 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -75,37 +75,22 @@ ;; cc-fix.el contains compatibility macros that should be used if ;; needed. -(eval-and-compile - (if (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2) - (not (fboundp 'push))) - (cc-load "cc-fix"))) - -(when (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS - ; to make the call to f-l-c-k throw an error. - (eval-after-load "font-lock" - '(if (and (not (featurep 'cc-fix)) ; only load the file once. - (let (font-lock-keywords) - (font-lock-compile-keywords '("\\<\\>")) - font-lock-keywords)) ; did the previous call foul this up? - (load "cc-fix")))) - -;; The above takes care of the delayed loading, but this is necessary -;; to ensure correct byte compilation. -(eval-when-compile - (if (and (featurep 'xemacs) - (not (featurep 'cc-fix)) - (progn - (require 'font-lock) - (let (font-lock-keywords) - (font-lock-compile-keywords '("\\<\\>")) - font-lock-keywords))) - (cc-load "cc-fix"))) - -;; XEmacs 21.4 doesn't have `delete-dups'. -(eval-and-compile - (if (and (not (fboundp 'delete-dups)) - (not (featurep 'cc-fix))) - (cc-load "cc-fix"))) +(cc-conditional-require + 'cc-fix (or (/= (regexp-opt-depth "\\(\\(\\)\\)") 2) + (not (fboundp 'push)) + ;; XEmacs 21.4 doesn't have `delete-dups'. + (not (fboundp 'delete-dups)))) + +(cc-conditional-require-after-load + 'cc-fix "font-lock" + (and + (featurep 'xemacs) + (progn + (require 'font-lock) + (let (font-lock-keywords) + (font-lock-compile-keywords '("\\<\\>")) + font-lock-keywords)))) + ;;; Variables also used at compile time. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 6572cee2cc7..dbc55f5e0ef 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -5964,7 +5964,7 @@ comment at the start of cc-engine.el for more info." ;; Recursive part of `c-forward-<>-arglist'. ;; ;; This function might do hidden buffer changes. - (let ((start (point)) res pos tmp + (let ((start (point)) res pos ;; Cover this so that any recorded found type ranges are ;; automatically lost if it turns out to not be an angle ;; bracket arglist. It's propagated through the return value @@ -6059,15 +6059,13 @@ comment at the start of cc-engine.el for more info." ;; Either an operator starting with '<' or a nested arglist. (setq pos (point)) (let (id-start id-end subres keyword-match) - (cond + (cond ;; The '<' begins a multi-char operator. ((looking-at c-<-op-cont-regexp) - (setq tmp (match-end 0)) (goto-char (match-end 0))) ;; We're at a nested <.....> ((progn - (setq tmp pos) - (backward-char) ; to the '<' + (backward-char) ; to the '<' (and (save-excursion ;; There's always an identifier before an angle @@ -6087,7 +6085,9 @@ comment at the start of cc-engine.el for more info." (and keyword-match (c-keyword-member (c-keyword-sym (match-string 1)) - 'c-<>-type-kwds))))))) + 'c-<>-type-kwds)))))) + (or subres (goto-char pos)) + subres) ;; It was an angle bracket arglist. (setq c-record-found-types subres) @@ -6103,11 +6103,11 @@ comment at the start of cc-engine.el for more info." (c-record-ref-id (cons id-start id-end)) (c-record-type-id (cons id-start id-end))))) - ;; At a "less than" operator. - (t - (forward-char) - ))) - t) ; carry on looping. + ;; At a "less than" operator. + (t + ;; (forward-char) ; NO! We've already gone over the <. + ))) + t) ; carry on looping. ((and (not c-restricted-<>-arglists) (or (and (eq (char-before) ?&) @@ -6666,49 +6666,65 @@ comment at the start of cc-engine.el for more info." (or res (goto-char here)) res)) +(defmacro c-back-over-list-of-member-inits () + ;; Go back over a list of elements, each looking like: + ;; <symbol> (<expression>) , + ;; or <symbol> {<expression>} , + ;; when we are putatively immediately after a comma. Stop when we don't see + ;; a comma. If either of <symbol> or bracketed <expression> is missing, + ;; throw nil to 'level. If the terminating } or ) is unmatched, throw nil + ;; to 'done. This is not a general purpose macro! + `(while (eq (char-before) ?,) + (backward-char) + (c-backward-syntactic-ws) + (when (not (memq (char-before) '(?\) ?}))) + (throw 'level nil)) + (when (not (c-go-list-backward)) + (throw 'done nil)) + (c-backward-syntactic-ws) + (when (not (c-simple-skip-symbol-backward)) + (throw 'level nil)) + (c-backward-syntactic-ws))) + (defun c-back-over-member-initializers () ;; Test whether we are in a C++ member initializer list, and if so, go back ;; to the introducing ":", returning the position of the opening paren of ;; the function's arglist. Otherwise return nil, leaving point unchanged. (let ((here (point)) (paren-state (c-parse-state)) - res) - + pos level-plausible at-top-level res) + ;; Assume tentatively that we're at the top level. Try to go back to the + ;; colon we seek. (setq res (catch 'done - (if (not (c-at-toplevel-p)) - (progn - (while (not (c-at-toplevel-p)) - (goto-char (c-pull-open-brace paren-state))) - (c-backward-syntactic-ws) - (when (not (c-simple-skip-symbol-backward)) - (throw 'done nil)) - (c-backward-syntactic-ws)) - (c-backward-syntactic-ws) - (when (memq (char-before) '(?\) ?})) - (when (not (c-go-list-backward)) - (throw 'done nil)) - (c-backward-syntactic-ws)) - (when (c-simple-skip-symbol-backward) - (c-backward-syntactic-ws))) - - (while (eq (char-before) ?,) - (backward-char) - (c-backward-syntactic-ws) - - (when (not (memq (char-before) '(?\) ?}))) - (throw 'done nil)) - (when (not (c-go-list-backward)) - (throw 'done nil)) - (c-backward-syntactic-ws) - (when (not (c-simple-skip-symbol-backward)) - (throw 'done nil)) - (c-backward-syntactic-ws)) - - (and - (eq (char-before) ?:) - (c-just-after-func-arglist-p)))) + (setq level-plausible + (catch 'level + (c-backward-syntactic-ws) + (when (memq (char-before) '(?\) ?})) + (when (not (c-go-list-backward)) + (throw 'done nil)) + (c-backward-syntactic-ws)) + (when (c-simple-skip-symbol-backward) + (c-backward-syntactic-ws)) + (c-back-over-list-of-member-inits) + (and (eq (char-before) ?:) + (c-just-after-func-arglist-p)))) + + (while (and (not (and level-plausible + (setq at-top-level (c-at-toplevel-p)))) + (setq pos (c-pull-open-brace paren-state))) ; might be a paren. + (setq level-plausible + (catch 'level + (goto-char pos) + (c-backward-syntactic-ws) + (when (not (c-simple-skip-symbol-backward)) + (throw 'level nil)) + (c-backward-syntactic-ws) + (c-back-over-list-of-member-inits) + (and (eq (char-before) ?:) + (c-just-after-func-arglist-p))))) + (and at-top-level level-plausible))) (or res (goto-char here)) res)) @@ -8048,6 +8064,8 @@ brace. Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info." + ;; Note to maintainers: this function consumes a great mass of CPU cycles. + ;; Its use should thus be minimized as far as possible. (let ((paren-state (c-parse-state))) (or (not (c-most-enclosing-brace paren-state)) (c-search-uplist-for-classkey paren-state)))) @@ -10052,7 +10070,8 @@ comment at the start of cc-engine.el for more info." ;; Note there is no limit on the backward search here, since member ;; init lists can, in practice, be very large. ((save-excursion - (when (setq placeholder (c-back-over-member-initializers)) + (when (and (c-major-mode-is 'c++-mode) + (setq placeholder (c-back-over-member-initializers))) (setq tmp-pos (point)))) (if (= (c-point 'bosws) (1+ tmp-pos)) (progn diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 7cda5ceaf1d..1a07c4cd699 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -403,7 +403,9 @@ The syntax tables aren't stored directly since they're quite large." table))) (c-lang-defvar c++-template-syntax-table (and (c-lang-const c++-make-template-syntax-table) - (funcall (c-lang-const c++-make-template-syntax-table)))) + ;; The next eval remove a superfluous ' from '(lambda. This + ;; gets rid of compilation warnings. + (funcall (eval (c-lang-const c++-make-template-syntax-table))))) (c-lang-defconst c-make-no-parens-syntax-table ;; A variant of the standard syntax table which is used to find matching @@ -426,7 +428,8 @@ The syntax tables aren't stored directly since they're quite large." table)))) (c-lang-defvar c-no-parens-syntax-table (and (c-lang-const c-make-no-parens-syntax-table) - (funcall (c-lang-const c-make-no-parens-syntax-table)))) + ;; See comment in `c++template-syntax-table' about the next `eval'. + (funcall (eval (c-lang-const c-make-no-parens-syntax-table))))) (c-lang-defconst c-identifier-syntax-modifications "A list that describes the modifications that should be done to the @@ -1430,6 +1433,14 @@ properly." "\\)\\s *")) (c-lang-setvar comment-start-skip (c-lang-const comment-start-skip)) +(c-lang-defconst comment-end-can-be-escaped + "When non-nil, escaped EOLs inside comments are valid. +This works in Emacs >= 25.1." + t nil + (c c++ objc) t) +(c-lang-setvar comment-end-can-be-escaped + (c-lang-const comment-end-can-be-escaped)) + (c-lang-defconst c-syntactic-ws-start ;; Regexp matching any sequence that can start syntactic whitespace. ;; The only uncertain case is '#' when there are cpp directives. diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index a46ee15ed5e..5d8af239972 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -99,10 +99,9 @@ (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs (cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1 -;; We set these variables during mode init, yet we don't require +;; We set this variable during mode init, yet we don't require ;; font-lock. (cc-bytecomp-defvar font-lock-defaults) -(cc-bytecomp-defvar font-lock-syntactic-keywords) ;; Menu support for both XEmacs and Emacs. If you don't have easymenu ;; with your version of Emacs, you are incompatible! @@ -479,7 +478,7 @@ preferably use the `c-mode-menu' language constant directly." and the line breaking/filling code. Intended to be used by other packages that embed CC Mode. -MODE is the CC Mode flavor to set up, e.g. 'c-mode or 'java-mode. +MODE is the CC Mode flavor to set up, e.g. `c-mode' or `java-mode'. DEFAULT-STYLE tells which indentation style to install. It has the same format as `c-default-style'. @@ -647,7 +646,7 @@ In addition to the work done by `c-basic-common-init' and customary in CC Mode modes but which aren't strictly necessary for CC Mode to operate correctly. -MODE is the symbol for the mode to initialize, like 'c-mode. See +MODE is the symbol for the mode to initialize, like `c-mode'. See `c-basic-common-init' for details. It's only optional to be compatible with old code; callers should always specify it." diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 9e2d625a4d4..f13906680cf 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -951,7 +951,7 @@ from a different message." (defvar compilation--previous-directory-cache nil "A pair (POS . RES) caching the result of previous directory search. Basically, this pair says that calling - (previous-single-property-change POS 'compilation-directory) + (previous-single-property-change POS \\='compilation-directory) returned RES, i.e. there is no change of `compilation-directory' between POS and RES.") (make-variable-buffer-local 'compilation--previous-directory-cache) @@ -967,7 +967,7 @@ POS and RES.") (t (setq compilation--previous-directory-cache nil)))) (defun compilation--previous-directory (pos) - "Like (previous-single-property-change POS 'compilation-directory), but faster." + "Like (previous-single-property-change POS \\='compilation-directory), but faster." ;; This avoids an N² behavior when there's no/few compilation-directory ;; entries, in which case each call to previous-single-property-change ;; ends up having to walk very far back to find the last change. @@ -2594,7 +2594,7 @@ and overlay is highlighted between MK and END-MK." (goto-char mk))) (if end-mk (push-mark end-mk t) - (if mark-active (setq mark-active))) + (if mark-active (setq mark-active nil))) ;; If hideshow got in the way of ;; seeing the right place, open permanently. (dolist (ov (overlays-at (point))) diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 3cf17f48b5f..faa917a87a7 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el @@ -664,7 +664,7 @@ otherwise make them unwritable." (defun cpp-edit-write (symbol branch) "Set which branches of SYMBOL should be writable to BRANCH. -BRANCH should be either nil (false branch), t (true branch) or 'both." +BRANCH should be either nil (false branch), t (true branch) or `both'." (interactive (list (cpp-choose-symbol) (cpp-choose-branch))) (setcar (nthcdr 3 (cpp-edit-list-entry-get-or-create symbol)) branch) (cpp-edit-reset)) diff --git a/lisp/progmodes/cwarn.el b/lisp/progmodes/cwarn.el index 2f501f28b65..eae96f01c3c 100644 --- a/lisp/progmodes/cwarn.el +++ b/lisp/progmodes/cwarn.el @@ -2,9 +2,8 @@ ;; Copyright (C) 1999-2015 Free Software Foundation, Inc. -;; Author: Anders Lindgren <andersl@andersl.com> +;; Author: Anders Lindgren ;; Keywords: c, languages, faces -;; X-Url: http://www.andersl.com/emacs ;; Version: 1.3.1 ;; This file is part of GNU Emacs. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 2c22483e86f..4cc2aee9346 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -228,8 +228,7 @@ Blank lines separate paragraphs. Semicolons start comments. \\{emacs-lisp-mode-map}" :group 'lisp - (defvar xref-backend-functions) - (defvar project-library-roots-function) + (defvar project-vc-external-roots-function) (lisp-mode-variables nil nil 'elisp) (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers) (setq-local electric-pair-text-pairs @@ -239,7 +238,7 @@ Blank lines separate paragraphs. Semicolons start comments. (add-function :before-until (local 'eldoc-documentation-function) #'elisp-eldoc-documentation-function) (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) - (setq-local project-library-roots-function #'elisp-library-roots) + (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)) @@ -576,8 +575,9 @@ It can be quoted, or be inside a quoted form." " " (cadr table-etc))) (cddr table-etc))))))))) -(define-obsolete-function-alias - 'lisp-completion-at-point 'elisp-completion-at-point "25.1") +(defun lisp-completion-at-point (_predicate) + (declare (obsolete elisp-completion-at-point "25.1")) + (elisp-completion-at-point)) ;;; Xref backend @@ -645,6 +645,7 @@ non-nil result supercedes the xrefs produced by ;; alphabetical by result type symbol ;; FIXME: advised function; list of advice functions + ;; FIXME: aliased variable ;; Coding system symbols do not appear in ‘load-history’, ;; so we can’t get a location for them. @@ -794,19 +795,7 @@ non-nil result supercedes the xrefs produced by xrefs)) -(declare-function project-library-roots "project") -(declare-function project-roots "project") -(declare-function project-current "project") - -(cl-defmethod xref-backend-references ((_backend (eql elisp)) symbol) - "Find all references to SYMBOL (a string) in the current project." - (cl-mapcan - (lambda (dir) - (xref-collect-references symbol dir)) - (let ((pr (project-current t))) - (append - (project-roots pr) - (project-library-roots pr))))) +(declare-function project-external-roots "project") (cl-defmethod xref-backend-apropos ((_backend (eql elisp)) regexp) (apply #'nconc @@ -843,9 +832,10 @@ non-nil result supercedes the xrefs produced by (cl-defmethod xref-location-group ((l xref-elisp-location)) (xref-elisp-location-file l)) -(defun elisp-library-roots () - (defvar package-user-dir) - (cons package-user-dir load-path)) +(defun elisp-load-path-roots () + (if (boundp 'package-user-dir) + (cons package-user-dir load-path) + load-path)) ;;; Elisp Interaction mode diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index ae1aa11fbc2..dbb46a38381 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -799,13 +799,12 @@ If no tags table is loaded, do nothing and return nil." (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) tags-case-fold-search case-fold-search)) - (pattern (funcall (or find-tag-default-function - (get major-mode 'find-tag-default-function) - #'find-tag-default))) + (pattern (find-tag--default)) beg) (when pattern (save-excursion - (forward-char (1- (length pattern))) + ;; Avoid end-of-buffer error. + (goto-char (+ (point) (length pattern) -1)) ;; The find-tag function might be overly optimistic. (when (search-backward pattern nil t) (setq beg (point)) @@ -817,9 +816,7 @@ If no tags table is loaded, do nothing and return nil." (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) tags-case-fold-search case-fold-search)) - (default (funcall (or find-tag-default-function - (get major-mode 'find-tag-default-function) - 'find-tag-default))) + (default (find-tag--default)) (spec (completing-read (if default (format "%s (default %s): " (substring string 0 (string-match "[ :]+\\'" string)) @@ -831,6 +828,11 @@ If no tags table is loaded, do nothing and return nil." (or default (user-error "There is no default tag")) spec))) +(defun find-tag--default () + (funcall (or find-tag-default-function + (get major-mode 'find-tag-default-function) + 'find-tag-default))) + (defvar last-tag nil "Last tag found by \\[find-tag].") @@ -1259,24 +1261,21 @@ buffer-local values of tags table format variables." (point-min) (point-max)))) (save-excursion (goto-char (point-min)) - ;; This monster regexp matches an etags tag line. - ;; \1 is the string to match; - ;; \2 is not interesting; - ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN - ;; \4 is not interesting; - ;; \5 is the explicitly-specified tag name. - ;; \6 is the line to start searching at; - ;; \7 is the char to start searching at. + ;; This regexp matches an explicit tag name or the place where + ;; it would start. (while (re-search-forward - "^\\(\\([^\177]*[^-a-zA-Z0-9_+*$:\177]+\\)?\ -\\([-a-zA-Z0-9_+*$?:]+\\)[^-a-zA-Z0-9_+*$?:\177]*\\)\177\ -\\(\\([^\n\001]+\\)\001\\)?\\([0-9]+\\)?,\\([0-9]+\\)?\n" + "[\f\t\n\r()=,; ]?\177\\\(?:\\([^\n\001]+\\)\001\\)?" nil t) - (push (prog1 (if (match-beginning 5) + (push (prog1 (if (match-beginning 1) ;; There is an explicit tag name. - (buffer-substring (match-beginning 5) (match-end 5)) - ;; No explicit tag name. Best guess. - (buffer-substring (match-beginning 3) (match-end 3))) + (buffer-substring (match-beginning 1) (match-end 1)) + ;; No explicit tag name. Backtrack a little, + ;; and look for the implicit one. + (goto-char (match-beginning 0)) + (skip-chars-backward "^\f\t\n\r()=,; ") + (prog1 + (buffer-substring (point) (match-beginning 0)) + (goto-char (match-end 0)))) (progress-reporter-update progress-reporter (point))) table))) table)) @@ -2086,18 +2085,15 @@ for \\[find-tag] (which see)." tag-implicit-name-match-p) "Tag order used in `xref-backend-definitions' to look for definitions.") +;;;###autoload +(defun etags--xref-backend () 'etags) + +(cl-defmethod xref-backend-identifier-at-point ((_backend (eql etags))) + (find-tag--default)) + (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags))) (tags-lazy-completion-table)) -(cl-defmethod xref-backend-references ((_backend (eql etags)) symbol) - (cl-mapcan - (lambda (dir) - (xref-collect-references symbol dir)) - (let ((pr (project-current t))) - (append - (project-roots pr) - (project-library-roots pr))))) - (cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol) (etags--xref-find-definitions symbol)) @@ -2158,9 +2154,6 @@ for \\[find-tag] (which see)." (with-slots (tag-info) l (nth 1 tag-info))) -(defun etags-library-roots () - (mapcar #'file-name-directory tags-table-list)) - (provide 'etags) diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 0e333f1f7ed..324efb0e1bb 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -295,7 +295,7 @@ the constant `f90-no-break-re' ensures that such tokens are not split." (defcustom f90-auto-keyword-case nil "Automatic case conversion of keywords. -The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil." +The options are `downcase-word', `upcase-word', `capitalize-word' and nil." :type '(choice (const downcase-word) (const upcase-word) (const capitalize-word) (const nil)) :safe (lambda (value) (memq value '(downcase-word @@ -2330,7 +2330,7 @@ Any other key combination is executed normally." ;; Change the keywords according to argument. (defun f90-change-keywords (change-word &optional beg end) "Change the case of F90 keywords in the region (if specified) or buffer. -CHANGE-WORD should be one of 'upcase-word, 'downcase-word, 'capitalize-word." +CHANGE-WORD should be one of `upcase-word', `downcase-word', `capitalize-word'." (save-excursion (setq beg (or beg (point-min)) end (or end (point-max))) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 3adadd1386e..882ac064b82 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -989,7 +989,7 @@ For the format of LINE-ERR-INFO, see `flymake-ler-make-ler'." (funcall flymake-get-project-include-dirs-function basedir)) (defun flymake-get-system-include-dirs () - "System include dirs - from the 'INCLUDE' env setting." + "System include dirs - from the `INCLUDE' env setting." (let* ((includes (getenv "INCLUDE"))) (if includes (split-string includes path-separator t) nil))) diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index ef470055065..33fe4b37cf8 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -1258,7 +1258,7 @@ Auto-indent does not happen if a numeric ARG is used." (defun fortran-previous-statement () "Move point to beginning of the previous Fortran statement. -Returns 'first-statement if that statement is the first +Returns `first-statement' if that statement is the first non-comment Fortran statement in the file, and nil otherwise. Directive lines are treated as comments." (interactive) @@ -1290,7 +1290,7 @@ Directive lines are treated as comments." (defun fortran-next-statement () "Move point to beginning of the next Fortran statement. -Returns 'last-statement if that statement is the last +Returns `last-statement' if that statement is the last non-comment Fortran statement in the file, and nil otherwise. Directive lines are treated as comments." (interactive) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 4bee7c1dfa2..bde030e3f26 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1630,7 +1630,7 @@ this trigger is subscribed to `gdb-buf-publisher' and called with (make-comint-in-buffer "gdb-inferior" (current-buffer) nil)) (defcustom gdb-display-io-nopopup nil - "When non-nil, and the 'gdb-inferior-io buffer is buried, don't pop it up." + "When non-nil, and the `gdb-inferior-io' buffer is buried, don't pop it up." :type 'boolean :group 'gdb :version "25.1") @@ -1766,7 +1766,8 @@ static char *magick[] = { (defvar gdb-control-commands-regexp (concat "^\\(" - "commands\\|if\\|while\\|define\\|document\\|python\\|" + "commands\\|if\\|while\\|define\\|document\\|" + "python\\|python-interactive\\|pi\\|guile\\|guile-repl\\|gr\\|" "while-stepping\\|stepping\\|ws\\|actions" "\\)\\([[:blank:]]+.*\\)?$") "Regexp matching GDB commands that enter a recursive reading loop. @@ -1782,21 +1783,27 @@ commands to be prefixed by \"-interpreter-exec console\".") (let ((inhibit-read-only t)) (remove-text-properties (point-min) (point-max) '(face)))) ;; mimic <RET> key to repeat previous command in GDB - (if (not (string= "" string)) - (if gdb-continuation - (setq gdb-last-command (concat gdb-continuation - (gdb-strip-string-backslash string) - " ")) - (setq gdb-last-command (gdb-strip-string-backslash string))) - (if gdb-last-command (setq string gdb-last-command)) - (setq gdb-continuation nil)) - (if (and (not gdb-continuation) (or (string-match "^-" string) - (> gdb-control-level 0))) + (when (= gdb-control-level 0) + (if (not (string= "" string)) + (if gdb-continuation + (setq gdb-last-command (concat gdb-continuation + (gdb-strip-string-backslash string) + " ")) + (setq gdb-last-command (gdb-strip-string-backslash string))) + (if gdb-last-command (setq string gdb-last-command)) + (setq gdb-continuation nil))) + (if (and (not gdb-continuation) + (or (string-match "^-" string) + (> gdb-control-level 0))) ;; Either MI command or we are feeding GDB's recursive reading loop. (progn (setq gdb-first-done-or-error t) (process-send-string proc (concat string "\n")) - (if (and (string-match "^end$" string) + (if (and (string-match + (concat "^\\(" + (if (eq system-type 'windows-nt) "\026" "\004") + "\\|,q\\|,quit\\|end\\)$") + string) (> gdb-control-level 0)) (setq gdb-control-level (1- gdb-control-level)))) ;; CLI command @@ -1812,7 +1819,11 @@ commands to be prefixed by \"-interpreter-exec console\".") (if gdb-enable-debug (push (cons 'mi-send to-send) gdb-debug-log)) (process-send-string proc to-send)) - (if (and (string-match "^end$" string) + (if (and (string-match + (concat "^\\(" + (if (eq system-type 'windows-nt) "\026" "\004") + "\\|,q\\|,quit\\|end\\)$") + string) (> gdb-control-level 0)) (setq gdb-control-level (1- gdb-control-level))) (setq gdb-continuation nil))) @@ -2788,7 +2799,7 @@ buffer with `gdb-bind-function-to-buffer'. If SIGNAL-LIST is non-nil, GDB-COMMAND is sent only when the defined trigger is called with an argument from SIGNAL-LIST. It's not recommended to define triggers with empty SIGNAL-LIST. -Normally triggers should respond at least to 'update signal. +Normally triggers should respond at least to the `update' signal. Normally the trigger defined by this command must be called from the buffer where HANDLER-NAME must work. This should be done so @@ -3252,7 +3263,7 @@ corresponding to the mode line clicked." "Define a NAME command which will act upon thread on the current line. CUSTOM-DEFUN may use locally bound `thread' variable, which will -be the value of 'gdb-thread property of the current line. +be the value of `gdb-thread' property of the current line. If `gdb-thread' is nil, error is signaled." `(defun ,name (&optional event) ,(when doc doc) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 1284ef2857a..024547cc487 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -3080,7 +3080,7 @@ the character after the end of the expr." "Scan from SPAN-START to SPAN-END for punctuation characters. If `->' is found, return `?.'. If `.' is found, return `?.'. If any other punctuation is found, return `??'. -If no punctuation is found, return `? '." +If no punctuation is found, return `?\\s'." (let ((result ?\s) (syntax)) (while (< span-start span-end) diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el index e0d25c4439d..71646d312c4 100644 --- a/lisp/progmodes/hideif.el +++ b/lisp/progmodes/hideif.el @@ -653,7 +653,7 @@ that form should be displayed.") (stringp id)))) (defun hif-define-operator (tokens) - "`Upgrade' hif-define xxx to '(hif-define xxx)' so it won't be substituted." + "\"Upgrade\" hif-define XXX to `(hif-define XXX)' so it won't be substituted." (let ((result nil) (tok nil)) (while (setq tok (pop tokens)) @@ -766,7 +766,7 @@ macros to prevent self-reference." (error "Error: unexpected token: %s" hif-token))))) (defun hif-exprlist () - "Parse an exprlist: expr { ',' expr}." + "Parse an exprlist: expr { `,' expr}." (let ((result (hif-expr))) (if (eq hif-token 'hif-comma) (let ((temp (list result))) @@ -780,7 +780,7 @@ macros to prevent self-reference." (defun hif-expr () "Parse an expression as found in #if. -expr : or-expr | or-expr '?' expr ':' expr." +expr : or-expr | or-expr `?' expr `:' expr." (let ((result (hif-or-expr)) middle) (while (eq hif-token 'hif-conditional) @@ -794,7 +794,7 @@ expr : or-expr | or-expr '?' expr ':' expr." result)) (defun hif-or-expr () - "Parse an or-expr : and-expr | or-expr '||' and-expr." + "Parse an or-expr : and-expr | or-expr `||' and-expr." (let ((result (hif-and-expr))) (while (eq hif-token 'hif-or) (hif-nexttoken) @@ -802,7 +802,7 @@ expr : or-expr | or-expr '?' expr ':' expr." result)) (defun hif-and-expr () - "Parse an and-expr : logior-expr | and-expr '&&' logior-expr." + "Parse an and-expr : logior-expr | and-expr `&&' logior-expr." (let ((result (hif-logior-expr))) (while (eq hif-token 'hif-and) (hif-nexttoken) @@ -810,7 +810,7 @@ expr : or-expr | or-expr '?' expr ':' expr." result)) (defun hif-logior-expr () - "Parse a logor-expr : logxor-expr | logor-expr '|' logxor-expr." + "Parse a logor-expr : logxor-expr | logor-expr `|' logxor-expr." (let ((result (hif-logxor-expr))) (while (eq hif-token 'hif-logior) (hif-nexttoken) @@ -818,7 +818,7 @@ expr : or-expr | or-expr '?' expr ':' expr." result)) (defun hif-logxor-expr () - "Parse a logxor-expr : logand-expr | logxor-expr '^' logand-expr." + "Parse a logxor-expr : logand-expr | logxor-expr `^' logand-expr." (let ((result (hif-logand-expr))) (while (eq hif-token 'hif-logxor) (hif-nexttoken) @@ -826,7 +826,7 @@ expr : or-expr | or-expr '?' expr ':' expr." result)) (defun hif-logand-expr () - "Parse a logand-expr : eq-expr | logand-expr '&' eq-expr." + "Parse a logand-expr : eq-expr | logand-expr `&' eq-expr." (let ((result (hif-eq-expr))) (while (eq hif-token 'hif-logand) (hif-nexttoken) @@ -866,7 +866,7 @@ expr : or-expr | or-expr '?' expr ':' expr." (defun hif-math () "Parse an expression with + or -. - math : muldiv | math '+|-' muldiv." + math : muldiv | math `+'|`-' muldiv." (let ((result (hif-muldiv-expr)) (math-op nil)) (while (memq hif-token '(hif-plus hif-minus)) @@ -877,7 +877,7 @@ expr : or-expr | or-expr '?' expr ':' expr." (defun hif-muldiv-expr () "Parse an expression with *,/,%. - muldiv : factor | muldiv '*|/|%' factor." + muldiv : factor | muldiv `*'|`/'|`%' factor." (let ((result (hif-factor)) (math-op nil)) (while (memq hif-token '(hif-multiply hif-divide hif-modulo)) @@ -888,8 +888,8 @@ expr : or-expr | or-expr '?' expr ':' expr." (defun hif-factor () "Parse a factor. -factor : '!' factor | '~' factor | '(' expr ')' | 'defined(' id ')' | - 'id(parmlist)' | strings | id." +factor : `!' factor | `~' factor | `(' expr `)' | `defined(' id `)' | + id `(' parmlist `)' | strings | id." (cond ((eq hif-token 'hif-not) (hif-nexttoken) @@ -999,9 +999,9 @@ This macro cannot be evaluated alone without parameters input." (defun hif-token-concat (a b) "Concatenate two tokens into a longer token. Currently support only simple token concatenation. Also support weird (but -valid) token concatenation like '>' ## '>' becomes '>>'. Here we take care only +valid) token concatenation like `>' ## `>' becomes `>>'. Here we take care only those that can be evaluated during preprocessing time and ignore all those that -can only be evaluated at C(++) runtime (like '++', '--' and '+='...)." +can only be evaluated at C(++) runtime (like `++', `--' and `+='...)." (if (or (memq a hif-valid-token-list) (memq b hif-valid-token-list)) (let* ((ra (car (rassq a hif-token-alist))) @@ -1632,8 +1632,8 @@ not be expanded." result)))) (defun hif-parse-macro-arglist (str) - "Parse argument list formatted as '( arg1 [ , argn] [...] )'. -The '...' is also included. Return a list of the arguments, if '...' exists the + "Parse argument list formatted as `( arg1 [ , argn] [...] )'. +The `...' is also included. Return a list of the arguments, if `...' exists the first arg will be `hif-etc'." (let* ((hif-simple-token-only nil) ; Dynamic binding var for `hif-tokenize' (tokenlist diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index dba497b1f41..7dfef5fae4c 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -439,9 +439,9 @@ See `hs-c-like-adjust-block-beginning' for an example of using this.") You can display this in the mode line by adding the symbol `hs-headline' to the variable `mode-line-format'. For example, - (unless (memq 'hs-headline mode-line-format) + (unless (memq \\='hs-headline mode-line-format) (setq mode-line-format - (append '(\"-\" hs-headline) mode-line-format))) + (append \\='(\"-\" hs-headline) mode-line-format))) Note that `mode-line-format' is buffer-local.") @@ -469,9 +469,9 @@ KIND is either `code' or `comment'. Optional fourth arg B-OFFSET when added to B specifies the actual buffer position where the block begins. Likewise for optional fifth arg E-OFFSET. If unspecified they are taken to be 0 (zero). The following properties are set -in the overlay: 'invisible 'hs 'hs-b-offset 'hs-e-offset. Also, +in the overlay: `invisible' `hs' `hs-b-offset' `hs-e-offset'. Also, depending on variable `hs-isearch-open', the following properties may -be present: 'isearch-open-invisible 'isearch-open-invisible-temporary. +be present: `isearch-open-invisible' `isearch-open-invisible-temporary'. If variable `hs-set-up-overlay' is non-nil it should specify a function to call with the newly initialized overlay." (unless b-offset (setq b-offset 0)) @@ -934,7 +934,7 @@ if ARG is omitted or nil. When hideshow minor mode is on, the menu bar is augmented with hideshow commands and the hideshow commands are enabled. -The value '(hs . t) is added to `buffer-invisibility-spec'. +The value (hs . t) is added to `buffer-invisibility-spec'. The main commands are: `hs-hide-all', `hs-show-all', `hs-hide-block', `hs-show-block', `hs-hide-level' and `hs-toggle-hiding'. There is also diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index ac2259df6a4..1546e9ad6e6 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -808,7 +808,7 @@ See `idlwave-check-abbrev'." (defcustom idlwave-abbrev-change-case nil "Non-nil means all abbrevs will be forced to either upper or lower case. If the value t, all expanded abbrevs will be upper case. -If the value is 'down then abbrevs will be forced to lower case. +If the value is `down' then abbrevs will be forced to lower case. If nil, the case will not change. If `idlwave-reserved-word-upcase' is non-nil, reserved words will always be upper case, regardless of this variable." @@ -963,7 +963,7 @@ a file." (defcustom idlwave-doc-modifications-keyword "HISTORY" "The modifications keyword to use with the log documentation commands. -A ':' is added to the keyword end. +A `:' is added to the keyword end. Inserted by doc-header and used to position logs by doc-modification. If nil it will not be inserted." :group 'idlwave-documentation @@ -999,7 +999,7 @@ it without compromising backwards-compatibility." (defcustom idlwave-shell-command-line-options nil "A list of command line options for calling the IDL program. Since IDL is executed directly without going through a shell like /bin/sh, -this should be a list of strings like '(\"-rt=file\" \"-nw\") with a separate +this should be a list of strings like (\"-rt=file\" \"-nw\") with a separate string for each argument. But you may also give a single string which contains the options whitespace-separated. Emacs will be kind enough to split it for you." @@ -1021,7 +1021,7 @@ Obsolete, if the IDL Assistant is being used for help." Will be used to bind debugging commands in the shell buffer and in all source buffers. These are additional convenience bindings, the debugging commands are always available with the `C-c C-d' prefix. -If you set this to '(control shift), this means setting a breakpoint will +If you set this to (control shift), this means setting a breakpoint will be on `C-S-b', compiling a source file on `C-S-c' etc. Possible modifiers are `control', `meta', `super', `hyper', `alt', and `shift'." :group 'idlwave-shell-general-setup @@ -1557,15 +1557,15 @@ KEY is a string - same as for the `define-key' function. CMD is a function of no arguments or a list to be evaluated. CMD is bound to KEY in `idlwave-mode-map' by defining an anonymous function calling `self-insert-command' followed by CMD. If KEY contains more than one -character a binding will only be set if SELECT is 'both. +character a binding will only be set if SELECT is `both'. \(KEY . CMD) is also placed in the `idlwave-indent-expand-table', replacing any previous value for KEY. If a binding is not set then it will instead be placed in `idlwave-indent-action-table'. If the optional argument SELECT is nil then an action and binding are -created. If SELECT is 'noaction, then a binding is always set and no -action is created. If SELECT is 'both then an action and binding +created. If SELECT is `noaction', then a binding is always set and no +action is created. If SELECT is `both' then an action and binding will both be created even if KEY contains more than one character. Otherwise, if SELECT is non-nil then only an action is created. @@ -2690,7 +2690,7 @@ statement." (append st (match-end 0)))))) (defun idlwave-expand-equal (&optional before after is-action) - "Pad '=' with spaces. + "Pad `=' with spaces. Two cases: Assignment statement, and keyword assignment. Which case is determined using `idlwave-start-of-substatement' and `idlwave-statement-type'. The equal sign will be surrounded by BEFORE @@ -2835,7 +2835,7 @@ ACTION is a list (REG . FUNC). REG is a regular expression. FUNC is either a function name to be called with `funcall' or a list to be evaluated with `eval'. The action performed by FUNC should leave point after the match for REG - otherwise an infinite loop may be -entered. FUNC is always passed a final argument of 'is-action, so it +entered. FUNC is always passed a final argument of `is-action', so it can discriminate between being run as an action, or a key binding." (let ((action-key (car action)) (action-routine (cdr action))) @@ -6240,7 +6240,7 @@ If yes, return the index (>=1)." (defun idlwave-all-method-classes (method &optional type) "Return all classes which have a method METHOD. -TYPE is 'fun or 'pro. +TYPE is `fun' or `pro'. When TYPE is not specified, both procedures and functions will be considered." (if (null method) (mapcar 'car (idlwave-class-alist)) @@ -6255,7 +6255,7 @@ When TYPE is not specified, both procedures and functions will be considered." (defun idlwave-all-method-keyword-classes (method keyword &optional type) "Return all classes which have a method METHOD with keyword KEYWORD. -TYPE is 'fun or 'pro. +TYPE is `fun' or `pro'. When TYPE is not specified, both procedures and functions will be considered." (if (or (null method) (null keyword)) @@ -6644,8 +6644,8 @@ This function is not general, can only be used for completion stuff." special-selector) "Perform TYPE completion of word before point against LIST. SELECTOR is the PREDICATE argument for the completion function. Show -PROMPT in echo area. TYPE is one of the intern types, e.g. 'function, -'procedure, 'class-tag, 'keyword, 'sysvar, etc. SPECIAL-SELECTOR is +PROMPT in echo area. TYPE is one of the intern types, e.g., `function', +`procedure', `class-tag', `keyword', `sysvar'. SPECIAL-SELECTOR is used only once, for `all-completions', and can be used to, e.g., accumulate information on matching completions." (let* ((completion-ignore-case t) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 3ce1c17352f..310b7ba371f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -97,7 +97,7 @@ name.") "\\.\\(" js--name-re "\\)\\s-*?=\\s-*?\\(function\\)\\_>") "Regexp matching an explicit JavaScript prototype \"method\" declaration. Group 1 is a (possibly-dotted) class name, group 2 is a method name, -and group 3 is the 'function' keyword.") +and group 3 is the `function' keyword.") (defconst js--plain-class-re (concat "^\\s-*\\(" js--dotted-name-re "\\)\\.prototype" @@ -831,7 +831,7 @@ lines." (defun js--forward-function-decl () "Move forward over a JavaScript function declaration. -This puts point at the 'function' keyword. +This puts point at the `function' keyword. If this is a syntactically-correct non-expression function, return the name of the function, or t if the name could not be @@ -1823,6 +1823,7 @@ nil." (skip-syntax-backward " ") (skip-syntax-backward "w_") (looking-at js--possibly-braceless-keyword-re)) + (memq (char-before) '(?\s ?\t ?\n ?\})) (not (js--end-of-do-while-loop-p)))) (save-excursion (goto-char (match-beginning 0)) @@ -3366,8 +3367,8 @@ left-to-right." (defun js--read-tab (prompt) "Read a Mozilla tab with prompt PROMPT. -Return a cons of (TYPE . OBJECT). TYPE is either 'window or -'tab, and OBJECT is a JavaScript handle to a ChromeWindow or a +Return a cons of (TYPE . OBJECT). TYPE is either `window' or +`tab', and OBJECT is a JavaScript handle to a ChromeWindow or a browser, respectively." ;; Prime IDO @@ -3778,12 +3779,12 @@ If one hasn't been set, or if it's stale, prompt for a new one." "Major mode for editing JSX. To customize the indentation for this mode, set the SGML offset -variables (`sgml-basic-offset', `sgml-attribute-offset' et al) +variables (`sgml-basic-offset', `sgml-attribute-offset' et al.) locally, like so: (defun set-jsx-indentation () (setq-local sgml-basic-offset js-indent-level)) - (add-hook 'js-jsx-mode-hook #'set-jsx-indentation)" + (add-hook \\='js-jsx-mode-hook #\\='set-jsx-indentation)" :group 'js (setq-local indent-line-function #'js-jsx-indent-line)) diff --git a/lisp/progmodes/mantemp.el b/lisp/progmodes/mantemp.el index a0f50fc0f19..79a60400eed 100644 --- a/lisp/progmodes/mantemp.el +++ b/lisp/progmodes/mantemp.el @@ -128,7 +128,7 @@ (defun mantemp-insert-cxx-syntax () "Insert C++ syntax around each template class and function. -Insert 'template class' for classes, 'template' for +Insert `template class' for classes, `template' for functions and add the statement delimiter `;' at the end of the lines." (save-excursion diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index 454367c10fa..904001d3383 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el @@ -236,8 +236,8 @@ The name of the function or case is included between the braces." "List of contexts where auto lineup of :'s or ='s should be done. Elements can be of type: `paramlist', `declaration' or `case', which will do auto lineup in parameterlist, declarations or case-statements -respectively. The word `all' will do all lineups. '(case paramlist) for -instance will do lineup in case-statements and parameterlist, while '(all) +respectively. The word `all' will do all lineups. (case paramlist) for +instance will do lineup in case-statements and parameterlist, while (all) will do all lineups." :type '(set :extra-offset 8 (const :tag "Everything" all) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index b459cbfd286..9702880771c 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -50,49 +50,51 @@ "Keymap used for programming modes.") (defvar prog-indentation-context nil - "Non-nil while indenting embedded code chunks. + "When non-nil, provides context for indenting embedded code chunks. + There are languages where part of the code is actually written in a sub language, e.g., a Yacc/Bison or ANTLR grammar also consists of plain C code. This variable enables the major mode of the -main language to use the indentation engine of the sub mode for -lines in code chunks written in the sub language. +main language to use the indentation engine of the sub-mode for +lines in code chunks written in the sub-mode's language. When a major mode of such a main language decides to delegate the indentation of a line/region to the indentation engine of the sub -mode, it is supposed to bind this variable to non-nil around the call. +mode, it should bind this variable to non-nil around the call. + +The non-nil value should be a list of the form: -The non-nil value looks as follows (FIRST-COLUMN (START . END) PREVIOUS-CHUNKS) -FIRST-COLUMN is the column the indentation engine of the sub mode -should usually choose for top-level language constructs inside -the code chunk (instead of 0). +FIRST-COLUMN is the column the indentation engine of the sub-mode +should use for top-level language constructs inside the code +chunk (instead of 0). -START to END is the region of the code chunk. See function -`prog-widen' for additional info. +START and END specify the region of the code chunk. END can be +nil, which stands for the value of `point-max'. The function +`prog-widen' uses this to restore restrictions imposed by the +sub-mode's indentation engine. PREVIOUS-CHUNKS, if non-nil, provides the indentation engine of -the sub mode with the virtual context of the code chunk. Valid +the sub-mode with the virtual context of the code chunk. Valid values are: - - A string containing code which the indentation engine can + - A string containing text which the indentation engine can consider as standing in front of the code chunk. To cache the string's calculated syntactic information for repeated calls - with the same string, it is valid and expected for the inner - mode to add text-properties to the string. + with the same string, the sub-mode can add text-properties to + the string. A typical use case is for grammars with code chunks which are - to be indented like function bodies - the string would contain - a corresponding function header. + to be indented like function bodies -- the string would contain + the corresponding function preamble. - - A function called with the start position of the current - chunk. It will return either the region of the previous chunk - as (PREV-START . PREV-END) or nil if there is no further - previous chunk. + - A function, to be called with the start position of the current + chunk. It should return either the region of the previous chunk + as (PREV-START . PREV-END), or nil if there is no previous chunk. - A typical use case are literate programming sources - the - function would successively return the code chunks of the - previous macro definitions for the same name.") + A typical use case are literate programming sources -- the + function would successively return the previous code chunks.") (defun prog-indent-sexp (&optional defun) "Indent the expression after point. @@ -113,8 +115,8 @@ instead." (defun prog-widen () "Remove restrictions (narrowing) from current code chunk or buffer. -This function can be used instead of `widen' in any function used -by the indentation engine to make it respect the value +This function should be used instead of `widen' in any function used +by the indentation engine to make it respect the value of `prog-indentation-context'. This function (like `widen') is useful inside a @@ -122,8 +124,8 @@ This function (like `widen') is useful inside a narrowing is in effect." (let ((chunk (cadr prog-indentation-context))) (if chunk - ;; no widen necessary here, as narrow-to-region changes (not - ;; just narrows) existing restrictions + ;; No call to `widen' is necessary here, as narrow-to-region + ;; changes (not just narrows) the existing restrictions (narrow-to-region (car chunk) (or (cdr chunk) (point-max))) (widen)))) @@ -134,15 +136,15 @@ Each element looks like (SYMBOL . CHARACTER), where the symbol matching SYMBOL (a string, not a regexp) will be shown as CHARACTER instead. -CHARACTER can be a character or it can be a list or vector, in +CHARACTER can be a character, or it can be a list or vector, in which case it will be used to compose the new symbol as per the third argument of `compose-region'.") (defun prettify-symbols-default-compose-p (start end _match) "Return true iff the symbol MATCH should be composed. The symbol starts at position START and ends at position END. -This is default `prettify-symbols-compose-predicate' which is -suitable for most programming languages such as C or Lisp." +This is the default for `prettify-symbols-compose-predicate' +which is suitable for most programming languages such as C or Lisp." ;; Check that the chars should really be composed into a symbol. (let* ((syntaxes-beg (if (memq (char-syntax (char-after start)) '(?w ?_)) '(?w ?_) '(?. ?\\))) @@ -154,14 +156,14 @@ suitable for most programming languages such as C or Lisp." (defvar-local prettify-symbols-compose-predicate #'prettify-symbols-default-compose-p - "A predicate deciding if the currently matched symbol is to be composed. + "A predicate for deciding if the currently matched symbol is to be composed. The matched symbol is the car of one entry in `prettify-symbols-alist'. -The predicate receives the match's start and end position as well +The predicate receives the match's start and end positions as well as the match-string as arguments.") (defun prettify-symbols--compose-symbol (alist) "Compose a sequence of characters into a symbol. -Regexp match data 0 points to the chars." +Regexp match data 0 specifies the characters to be composed." ;; Check that the chars should really be composed into a symbol. (let ((start (match-beginning 0)) (end (match-end 0)) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 398339ee590..c8e48e2275a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -20,13 +20,65 @@ ;;; Commentary: ;; This file contains generic infrastructure for dealing with -;; projects, and a number of public functions: finding the current -;; root, related project directories, and library directories. This -;; list is to be extended in future versions. +;; projects, some utility functions, and commands using that +;; infrastructure. ;; ;; The goal is to make it easier for Lisp programs to operate on the ;; current project, without having to know which package handles ;; detection of that project type, parsing its config files, etc. +;; +;; Infrastructure: +;; +;; Function `project-current', to determine the current project +;; instance, and 3 (at the moment) generic functions that act on it. +;; This list is to be extended in future versions. +;; +;; Utils: +;; +;; `project-combine-directories' and `project-subtract-directories', +;; mainly for use in the abovementioned generics' implementations. +;; +;; Commands: +;; +;; `project-find-regexp' and `project-or-external-find-regexp' use the +;; current API, and thus will work in any project that has an adapter. + +;;; TODO: + +;; * Commands `project-find-file' and `project-or-external-find-file'. +;; Currently blocked on adding a new completion style that would let +;; the user enter just the base file name (or a part of it), and get +;; it expanded to the absolute file name. +;; +;; * Build tool related functionality. Start with a `project-build' +;; command, which should provide completions on tasks to run, and +;; maybe allow entering some additional arguments. This might +;; be handled better with a separate API, though. Then we won't +;; force every project backend to be aware of the build tool(s) the +;; project is using. +;; +;; * Command to (re)build the tag files in all project roots. To that +;; end, we might need to add a way to provide file whitelist +;; wildcards for each root to limit etags to certain files (in +;; addition to the blacklist provided by ignores), and/or allow +;; specifying additional tag regexps. +;; +;; * UI for the user to be able to pick the current project for the +;; whole Emacs session, independent of the current directory. Or, +;; in the more advanced case, open a set of projects, and have some +;; project-related commands to use them all. E.g., have a command +;; to search for a regexp across all open projects. Provide a +;; history of projects that were opened in the past (storing it as a +;; list of directories should suffice). +;; +;; * Support for project-local variables: a UI to edit them, and a +;; utility function to retrieve a value. Probably useless without +;; support in various built-in commands. In the API, we might get +;; away with only adding a `project-configuration-directory' method, +;; defaulting to the project root the current file/buffer is in. +;; And prompting otherwise. How to best mix that with backends that +;; want to set/provide certain variables themselves, is up for +;; discussion. ;;; Code: @@ -38,35 +90,6 @@ Each functions on this hook is called in turn with one argument (the directory) and should return either nil to mean that it is not applicable, or a project instance.") -;; FIXME: Using the current approach, major modes are supposed to set -;; this variable to a buffer-local value. So we don't have access to -;; the "library roots" of language A from buffers of language B, which -;; seems desirable in multi-language projects, at least for some -;; potential uses, like "jump to a file in project or library". -;; -;; We can add a second argument to this function: a file extension, or -;; a language name. Some projects will know the set of languages used -;; in them; for others, like VC-based projects, we'll need -;; auto-detection. I see two options: -;; -;; - That could be implemented as a separate second hook, with a -;; list of functions that return file extensions. -;; -;; - This variable will be turned into a hook with "append" semantics, -;; and each function in it will perform auto-detection when passed -;; nil instead of an actual file extension. Then this hook will, in -;; general, be modified globally, and not from major mode functions. -(defvar project-library-roots-function 'etags-library-roots - "Function that returns a list of library roots. - -It should return a list of directories that contain source files -related to the current buffer. Depending on the language, it -should include the headers search path, load path, class path, -and so on. - -The directory names should be absolute. Used in the default -implementation of `project-library-roots'.") - ;;;###autoload (defun project-current (&optional maybe-prompt dir) "Return the project instance in DIR or `default-directory'. @@ -86,40 +109,35 @@ the user for a different directory to look in." (defun project--find-in-directory (dir) (run-hook-with-args-until-success 'project-find-functions dir)) -;; FIXME: Add MODE argument, like in `ede-source-paths'? -(cl-defgeneric project-library-roots (project) - "Return the list of library roots for PROJECT. +(cl-defgeneric project-roots (project) + "Return the list of directory roots of the current project. -It's the list of directories outside of the project that contain -related source files. +Most often it's just one directory which contains the project +build file and everything else in the project. But in more +advanced configurations, a project can span multiple directories. -Project-specific version of `project-library-roots-function', -which see. Unless it knows better, a specialized implementation -should use the value returned by that function." - (project-subtract-directories - (project-combine-directories - (funcall project-library-roots-function)) - (project-roots project))) - -(cl-defgeneric project-roots (project) - "Return the list of directory roots belonging to the current project. +The directory names should be absolute.") -Most often it's just one directory, which contains the project -file and everything else in the project. But in more advanced -configurations, a project can span multiple directories. +;; FIXME: Add MODE argument, like in `ede-source-paths'? +(cl-defgeneric project-external-roots (_project) + "Return the list of external roots for PROJECT. -The rule of thumb for whether to include a directory here, and not -in `project-library-roots', is whether its contents are meant to -be edited together with the rest of the project. +It's the list of directories outside of the project that are +still related to it. If the project deals with source code then, +depending on the languages used, this list should include the +headers search path, load path, class path, and so on. -The directory names should be absolute.") +The rule of thumb for whether to include a directory here, and +not in `project-roots', is whether its contents are meant to be +edited together with the rest of the project." + nil) (cl-defgeneric project-ignores (_project _dir) "Return the list of glob patterns to ignore inside DIR. Patterns can match both regular files and directories. To root an entry, start it with `./'. To match directories only, end it with `/'. DIR must be one of `project-roots' or -`project-library-roots'." +`project-external-roots'." (require 'grep) (defvar grep-find-ignored-files) (nconc @@ -133,17 +151,46 @@ end it with `/'. DIR must be one of `project-roots' or "Project implementation using the VC package." :group 'tools) -(defcustom project-vc-library-roots nil - "List ot directories to include in `project-library-roots'. -The file names can be absolute, or relative to the project root." - :type '(repeat file) - :safe 'listp) - (defcustom project-vc-ignores nil "List ot patterns to include in `project-ignores'." :type '(repeat string) :safe 'listp) +;; FIXME: Using the current approach, major modes are supposed to set +;; this variable to a buffer-local value. So we don't have access to +;; the "external roots" of language A from buffers of language B, which +;; seems desirable in multi-language projects, at least for some +;; potential uses, like "jump to a file in project or external dirs". +;; +;; We could add a second argument to this function: a file extension, +;; or a language name. Some projects will know the set of languages +;; used in them; for others, like VC-based projects, we'll need +;; auto-detection. I see two options: +;; +;; - That could be implemented as a separate second hook, with a +;; list of functions that return file extensions. +;; +;; - This variable will be turned into a hook with "append" semantics, +;; and each function in it will perform auto-detection when passed +;; nil instead of an actual file extension. Then this hook will, in +;; general, be modified globally, and not from major mode functions. +;; +;; The second option seems simpler, but the first one has the +;; advantage that the user could override the list of languages used +;; in a project via a directory-local variable, thus skipping +;; languages they're not working on personally (in a big project), or +;; working around problems in language detection (the detection logic +;; might be imperfect for the project in question, or it might work +;; too slowly for the user's taste). +(defvar project-vc-external-roots-function (lambda () tags-table-list) + "Function that returns a list of external roots. + +It should return a list of directory roots that contain source +files related to the current buffer. + +The directory names should be absolute. Used in the VC project +backend implementation of `project-external-roots'.") + (defun project-try-vc (dir) (let* ((backend (ignore-errors (vc-responsible-backend dir))) (root (and backend (ignore-errors @@ -153,15 +200,12 @@ The file names can be absolute, or relative to the project root." (cl-defmethod project-roots ((project (head vc))) (list (cdr project))) -(cl-defmethod project-library-roots ((project (head vc))) +(cl-defmethod project-external-roots ((project (head vc))) (project-subtract-directories (project-combine-directories - (append - (let ((root (cdr project))) - (mapcar - (lambda (dir) (file-name-as-directory (expand-file-name dir root))) - (project--value-in-dir 'project-vc-library-roots root))) - (funcall project-library-roots-function))) + (mapcar + #'file-name-as-directory + (funcall project-vc-external-roots-function))) (project-roots project))) (cl-defmethod project-ignores ((project (head vc)) dir) @@ -213,10 +257,11 @@ DIRS must contain directory names." (declare-function grep-read-files "grep") (declare-function xref-collect-matches "xref") (declare-function xref--show-xrefs "xref") +(declare-function xref-backend-identifier-at-point "xref") ;;;###autoload (defun project-find-regexp (regexp) - "Find all matches for REGEXP in the current project. + "Find all matches for REGEXP in the current project's roots. With \\[universal-argument] prefix, you can specify the directory to search in, and the file name pattern to search for." (interactive (list (project--read-regexp))) @@ -228,22 +273,20 @@ to search in, and the file name pattern to search for." (project--find-regexp-in dirs regexp pr))) ;;;###autoload -(defun project-or-libraries-find-regexp (regexp) - "Find all matches for REGEXP in the current project or libraries. +(defun project-or-external-find-regexp (regexp) + "Find all matches for REGEXP in the project roots or external roots. 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-library-roots pr)))) + (project-external-roots pr)))) (project--find-regexp-in dirs regexp pr))) (defun project--read-regexp () - (defvar xref-identifier-at-point-function) - (require 'xref) (read-regexp "Find regexp" - (funcall xref-identifier-at-point-function))) + (xref-backend-identifier-at-point (xref-find-backend)))) (defun project--find-regexp-in (dirs regexp project) (require 'grep) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b6f7da65752..04542cdff3d 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -273,7 +273,7 @@ (autoload 'help-function-arglist "help-fns") ;;;###autoload -(add-to-list 'auto-mode-alist (cons (purecopy "\\.py\\'") 'python-mode)) +(add-to-list 'auto-mode-alist (cons (purecopy "\\.pyw?\\'") 'python-mode)) ;;;###autoload (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode)) @@ -485,7 +485,7 @@ The type returned can be `comment', `string' or `paren'." ((nth 1 ppss) 'paren)))) (defsubst python-syntax-comment-or-string-p (&optional ppss) - "Return non-nil if PPSS is inside 'comment or 'string." + "Return non-nil if PPSS is inside comment or string." (nth 8 (or ppss (syntax-ppss)))) (defsubst python-syntax-closing-paren-p () @@ -1842,7 +1842,7 @@ This command assumes point is not in a string or comment." (defun python-nav-if-name-main () "Move point at the beginning the __main__ block. -When \"if __name__ == '__main__':\" is found returns its +When \"if __name__ == \\='__main__\\=':\" is found returns its position, else returns nil." (interactive) (let ((point (point)) @@ -3051,7 +3051,7 @@ the python shell: (defun python-shell-send-region (start end &optional send-main msg) "Send the region delimited by START and END to inferior Python process. When optional argument SEND-MAIN is non-nil, allow execution of -code inside blocks delimited by \"if __name__== '__main__':\". +code inside blocks delimited by \"if __name__== \\='__main__\\=':\". When called interactively SEND-MAIN defaults to nil, unless it's called with prefix argument. When optional argument MSG is non-nil, forces display of a user-friendly message if there's no @@ -3068,7 +3068,7 @@ process running; defaults to t when called interactively." (defun python-shell-send-buffer (&optional send-main msg) "Send the entire buffer to inferior Python process. When optional argument SEND-MAIN is non-nil, allow execution of -code inside blocks delimited by \"if __name__== '__main__':\". +code inside blocks delimited by \"if __name__== \\='__main__\\=':\". When called interactively SEND-MAIN defaults to nil, unless it's called with prefix argument. When optional argument MSG is non-nil, forces display of a user-friendly message if there's no diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 09338860c75..df07083eaef 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -2193,8 +2193,9 @@ See `font-lock-syntax-table'.") ;; Constants. ("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 1 (unless (eq ?\( (char-after)) font-lock-type-face)) - ("\\(^\\s *\\|[[{(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" - (2 font-lock-constant-face)) + ;; Ruby 1.9-style symbol hash keys. + ("\\(?:^\\s *\\|[[{(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+:\\)[^:]" + (1 (progn (forward-char -1) font-lock-constant-face))) ;; Conversion methods on Kernel. (,(concat ruby-font-lock-keyword-beg-re (regexp-opt '("Array" "Complex" "Float" "Hash" @@ -2257,9 +2258,10 @@ See `font-lock-syntax-table'.") ;;;###autoload (add-to-list 'auto-mode-alist - (cons (purecopy (concat "\\(?:\\." - "rb\\|ru\\|rake\\|thor" + (cons (purecopy (concat "\\(?:\\.\\(?:" + "rbw?\\|ru\\|rake\\|thor" "\\|jbuilder\\|rabl\\|gemspec\\|podspec" + "\\)" "\\|/" "\\(?:Gem\\|Rake\\|Cap\\|Thor" "\\|Puppet\\|Berks" diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index baed27bb138..394e9ca48c6 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -204,6 +204,7 @@ (autoload 'comint-completion-at-point "comint") (autoload 'comint-filename-completion "comint") +(autoload 'comint-send-string "comint") (autoload 'shell-command-completion "shell") (autoload 'shell-environment-variable-completion "shell") @@ -1450,7 +1451,7 @@ This is for the rc shell." (defun sh-mkword-regexpr (word) "Make a regexp which matches WORD as a word. This specifically excludes an occurrence of WORD followed by -punctuation characters like '-'." +punctuation characters like `-'." (concat word "\\([^-[:alnum:]_]\\|$\\)")) (defconst sh-re-done (sh-mkword-regexpr "done")) @@ -1580,7 +1581,8 @@ assumed. Since filenames rarely give a clue, they are not further analyzed. This mode adapts to the variations between shells (see `sh-set-shell') by means of an inheritance based feature lookup (see `sh-feature'). This mechanism applies to all variables (including skeletons) that pertain to -shell-specific features. +shell-specific features. Shell script files can use the `sh-shell' local +variable to indicate the shell variant to be used for the file. The default style of this mode is that of Rosenblatt's Korn shell book. The syntax of the statements varies with the shell being used. The @@ -2364,7 +2366,11 @@ argument) controls whether to insert a #!-line and think about making the visited file executable, and NO-QUERY-FLAG (the second argument) controls whether to query about making the visited file executable. -Calls the value of `sh-set-shell-hook' if set." +Calls the value of `sh-set-shell-hook' if set. + +Shell script files can cause this function be called automatically +when the file is visited by having a `sh-shell' file-local variable +whose value is the shell name (don't quote it)." (interactive (list (completing-read (format "Shell (default %s): " sh-shell-file) diff --git a/lisp/progmodes/simula.el b/lisp/progmodes/simula.el index bc0133805ee..d3ee9b5b4b2 100644 --- a/lisp/progmodes/simula.el +++ b/lisp/progmodes/simula.el @@ -344,22 +344,22 @@ Variables controlling indentation style: with respect to the previous line of the statement. `simula-label-offset' -4711 Offset of SIMULA label lines relative to usual indentation. - `simula-if-indent' '(0 . 0) + `simula-if-indent' (0 . 0) Extra indentation of THEN and ELSE with respect to the starting IF. Value is a cons cell, the car is extra THEN indentation and the cdr extra ELSE indentation. IF after ELSE is indented as the starting IF. - `simula-inspect-indent' '(0 . 0) + `simula-inspect-indent' (0 . 0) Extra indentation of WHEN and OTHERWISE with respect to the corresponding INSPECT. Value is a cons cell, the car is extra WHEN indentation and the cdr extra OTHERWISE indentation. `simula-electric-indent' nil If this variable is non-nil, `simula-indent-line' will check the previous line to see if it has to be reindented. - `simula-abbrev-keyword' 'upcase + `simula-abbrev-keyword' `upcase' Determine how SIMULA keywords will be expanded. Value is one of the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table', or nil if they should not be changed. - `simula-abbrev-stdproc' 'abbrev-table + `simula-abbrev-stdproc' `abbrev-table' Determine how standard SIMULA procedure and class names will be expanded. Value is one of the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table', or nil if they should not be changed. diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index abc99eec909..40596749de7 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -2987,7 +2987,7 @@ supported: :number t In order to ask the user for username, password and database, call the -function like this: (sql-get-login 'user 'password 'database)." +function like this: (sql-get-login \\='user \\='password \\='database)." (dolist (w what) (let ((plist (cdr-safe w))) (pcase (or (car-safe w) w) @@ -4891,7 +4891,7 @@ your might try undecided-dos as a coding system. If this doesn't help, Try to set `comint-output-filter-functions' like this: \(setq comint-output-filter-functions (append comint-output-filter-functions - '(comint-strip-ctrl-m))) + \\='(comint-strip-ctrl-m))) \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" (interactive "P") diff --git a/lisp/progmodes/vera-mode.el b/lisp/progmodes/vera-mode.el index bce56a447f0..354002dd3b3 100644 --- a/lisp/progmodes/vera-mode.el +++ b/lisp/progmodes/vera-mode.el @@ -870,7 +870,7 @@ This function does not modify point or mark." (beginning-of-line))))))) (defmacro vera-prepare-search (&rest body) - "Execute BODY with a syntax table that includes '_'." + "Execute BODY with a syntax table that includes `_'." `(with-syntax-table vera-mode-ext-syntax-table ,@body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 4095d47b5a9..90145ddff8b 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -757,7 +757,7 @@ Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'." (put 'verilog-auto-wire-type 'safe-local-variable `stringp) (defcustom verilog-auto-endcomments t - "Non-nil means insert a comment /* ... */ after 'end's. + "Non-nil means insert a comment /* ... */ after `end's. The name of the function or case will be set between the braces." :group 'verilog-mode-actions :type 'boolean) @@ -797,7 +797,7 @@ needed on every save. A value of `detect' will do \\[verilog-auto] automatically when it thinks necessary. A value of `ask' will query the user when it thinks updating is needed. -You should not rely on the 'ask or 'detect policies, they are safeguards +You should not rely on the `ask' or `detect' policies, they are safeguards only. They do not detect when AUTOINSTs need to be updated because a sub-module's port list has changed." :group 'verilog-mode-actions @@ -3733,12 +3733,12 @@ Variables controlling indentation/edit style: will be inserted. Setting this variable to zero results in every end acquiring a comment; the default avoids too many redundant comments in tight quarters. - `verilog-auto-lineup' (default 'declarations) + `verilog-auto-lineup' (default `declarations') List of contexts where auto lineup of code should be done. Variables controlling other actions: - `verilog-linter' (default surelint) + `verilog-linter' (default `surelint') Unix program to call to run the lint checker. This is the default command for \\[compile-command] and \\[verilog-auto-save-compile]. @@ -4089,7 +4089,7 @@ The upper left corner is defined by point. Indices begin with 0 and extend to the MAX - 1. If no prefix arg is given, the user is prompted for a value. The indices are surrounded by square brackets []. For example, the following code with the point -located after the first 'a' gives: +located after the first `a' gives: a = b a[ 0] = b a = b a[ 1] = b @@ -12949,7 +12949,7 @@ used on the right hand side of assignments. By default, AUTORESET will include the width of the signal in the autos, SystemVerilog designs may want to change this. To control this behavior, see `verilog-auto-reset-widths'. In some cases -AUTORESET must use a '0 assignment and it will print NOWIDTH; use +AUTORESET must use a \\='0 assignment and it will print NOWIDTH; use `verilog-auto-reset-widths' unbased to prevent this. AUTORESET ties signals to deasserted, which is presumed to be zero. diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 9ee4ab520e1..09330d76dcd 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -585,7 +585,7 @@ option `vhdl-file-header'). The default directory must have an absolute path (use `M-TAB' for completion). All other paths can be absolute or relative to the default directory. All -paths must end with '/'. +paths must end with `/'. The design units found in the sources (files and directories) are shown in the hierarchy browser. Path and file name can contain wildcards `*' and `?' as @@ -945,7 +945,7 @@ If nil, only a list of actual parameters is entered." :group 'vhdl-template) (defcustom vhdl-sensitivity-list-all t - "Non-nil means use 'all' keyword in sensitivity list." + "Non-nil means use `all' keyword in sensitivity list." :version "25.1" :type 'boolean :group 'vhdl-template) @@ -1103,7 +1103,7 @@ Otherwise, falling edge triggers." (defcustom vhdl-clock-edge-condition 'standard "Syntax of the clock edge condition. - Standard: \"clk'event and clk = '1'\" + Standard: \"clk\\='event and clk = \\='1\\='\" Function: \"rising_edge(clk)\"" :type '(choice (const :tag "Standard" standard) (const :tag "Function" function)) @@ -2477,7 +2477,7 @@ current buffer if no project is defined." default-directory)) (defmacro vhdl-prepare-search-1 (&rest body) - "Enable case insensitive search and switch to syntax table that includes '_', + "Enable case insensitive search and switch to syntax table that includes `_', then execute BODY, and finally restore the old environment. Used for consistent searching." `(let ((case-fold-search t)) ; case insensitive search @@ -2486,7 +2486,7 @@ consistent searching." ,@body))) (defmacro vhdl-prepare-search-2 (&rest body) - "Enable case insensitive search, switch to syntax table that includes '_', + "Enable case insensitive search, switch to syntax table that includes `_', arrange to ignore `intangible' overlays, then execute BODY, and finally restore the old environment. Used for consistent searching." `(let ((case-fold-search t) ; case insensitive search @@ -2759,7 +2759,7 @@ elements > `vhdl-menu-max-size'." (defun vhdl-function-name (prefix string &optional postfix) "Generate a Lisp function name. -PREFIX, STRING and optional POSTFIX are concatenated by '-' and spaces in +PREFIX, STRING and optional POSTFIX are concatenated by `-' and spaces in STRING are replaced by `-' and substrings are converted to lower case." (let ((name prefix)) (while (string-match "\\(\\w+\\)\\s-*\\(.*\\)" string) @@ -8189,8 +8189,8 @@ options vhdl-upper-case-{keywords,types,attributes,enum-values}." (defun vhdl-fix-statement-region (beg end &optional arg) "Force statements in region on separate line except when on same line -with 'end' keyword (necessary for correct indentation). -Currently supported keywords: 'begin', 'if'." +with `end' keyword (necessary for correct indentation). +Currently supported keywords: `begin', `if'." (interactive "r\nP") (vhdl-prepare-search-2 (let (point) @@ -8236,7 +8236,7 @@ Currently supported keywords: 'begin', 'if'." (defun vhdl-fix-statement-buffer () "Force statements in buffer on separate line except when on same line -with 'end' keyword (necessary for correct indentation)." +with `end' keyword (necessary for correct indentation)." (interactive) (vhdl-fix-statement-region (point-min) (point-max))) @@ -10578,22 +10578,22 @@ specification, if not already there." (insert "-- pragma " directive)) (defun vhdl-template-directive-translate-on () - "Insert directive 'translate_on'." + "Insert directive `translate_on'." (interactive) (vhdl-template-directive "translate_on")) (defun vhdl-template-directive-translate-off () - "Insert directive 'translate_off'." + "Insert directive `translate_off'." (interactive) (vhdl-template-directive "translate_off")) (defun vhdl-template-directive-synthesis-on () - "Insert directive 'synthesis_on'." + "Insert directive `synthesis_on'." (interactive) (vhdl-template-directive "synthesis_on")) (defun vhdl-template-directive-synthesis-off () - "Insert directive 'synthesis_off'." + "Insert directive `synthesis_off'." (interactive) (vhdl-template-directive "synthesis_off")) @@ -13307,7 +13307,7 @@ File statistics: \"%s\"\n\ (defconst vhdl-font-lock-syntactic-keywords '(("\\('\\).\\('\\)" (1 (7 . ?\')) (2 (7 . ?\')))) - "Mark single quotes as having string quote syntax in 'c' instances.") + "Mark single quotes as having string quote syntax in `c' instances.") (defvar vhdl-font-lock-keywords nil "Regular expressions to highlight in VHDL Mode.") @@ -17760,7 +17760,7 @@ Release Notes for VHDL Mode 3.37 - Context declaration - Block comments - Directives - - 'all' keyword in sensitivity list + - `all' keyword in sensitivity list Release Notes for VHDL Mode 3.34 diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 6a3b42ff646..abb9cc6361d 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -201,20 +201,22 @@ LENGTH is the match length, in characters." ;;; API -;; We make the etags backend the default for now, until something -;; better comes along. -(defvar xref-backend-functions (list #'xref--etags-backend) +(defvar xref-backend-functions nil "Special hook to find the xref backend for the current context. Each functions on this hook is called in turn with no arguments and should return either nil to mean that it is not applicable, or an xref backend, which is a value to be used to dispatch the generic functions.") +;; We make the etags backend the default for now, until something +;; better comes along. Use APPEND so that any `add-hook' calls made +;; before this package is loaded put new items before this one. +(add-hook 'xref-backend-functions #'etags--xref-backend t) + +;;;###autoload (defun xref-find-backend () (run-hook-with-args-until-success 'xref-backend-functions)) -(defun xref--etags-backend () 'etags) - (cl-defgeneric xref-backend-definitions (backend identifier) "Find definitions of IDENTIFIER. @@ -230,10 +232,21 @@ IDENTIFIER can be any string returned by To create an xref object, call `xref-make'.") -(cl-defgeneric xref-backend-references (backend identifier) +(cl-defgeneric xref-backend-references (_backend identifier) "Find references of IDENTIFIER. The result must be a list of xref objects. If no references can -be found, return nil.") +be found, return nil. + +The default implementation uses `semantic-symref-tool-alist' to +find a search tool; by default, this uses \"find | grep\" in the +`project-current' roots." + (cl-mapcan + (lambda (dir) + (xref-collect-references identifier dir)) + (let ((pr (project-current t))) + (append + (project-roots pr) + (project-external-roots pr))))) (cl-defgeneric xref-backend-apropos (backend pattern) "Find all symbols that match PATTERN. @@ -345,10 +358,10 @@ elements is negated." (interactive) (let ((ring xref--marker-ring)) (when (ring-empty-p ring) - (error "Marker stack is empty")) + (user-error "Marker stack is empty")) (let ((marker (ring-remove ring 0))) (switch-to-buffer (or (marker-buffer marker) - (error "The marked buffer has been deleted"))) + (user-error "The marked buffer has been deleted"))) (goto-char (marker-position marker)) (set-marker marker nil nil) (run-hooks 'xref-after-return-hook)))) @@ -498,7 +511,9 @@ WINDOW controls how the buffer is displayed: (save-excursion (let* ((loc (xref-item-location item)) (beg (xref-location-marker loc)) - (len (xref-match-length item))) + (end (move-marker (make-marker) + (+ beg (xref-match-length item)) + (marker-buffer beg)))) ;; Perform sanity check first. (xref--goto-location loc) ;; FIXME: The check should probably be a generic @@ -510,17 +525,18 @@ WINDOW controls how the buffer is displayed: (line-end-position)) (xref-item-summary item)) (user-error "Search results out of date")) - (push (cons beg len) pairs))))) + (push (cons beg end) pairs))))) (setq pairs (nreverse pairs))) (unless pairs (user-error "No suitable matches here")) (xref--query-replace-1 from to pairs)) (dolist (pair pairs) - (move-marker (car pair) nil))))) + (move-marker (car pair) nil) + (move-marker (cdr pair) nil))))) ;; FIXME: Write a nicer UI. (defun xref--query-replace-1 (from to pairs) (let* ((query-replace-lazy-highlight nil) - current-beg current-len current-buf + current-beg current-end current-buf ;; Counteract the "do the next match now" hack in ;; `perform-replace'. And still, it'll report that those ;; matches were "filtered out" at the end. @@ -529,18 +545,18 @@ WINDOW controls how the buffer is displayed: (and current-beg (eq (current-buffer) current-buf) (>= beg current-beg) - (<= end (+ current-beg current-len))))) + (<= end current-end)))) (replace-re-search-function (lambda (from &optional _bound noerror) (let (found pair) (while (and (not found) pairs) (setq pair (pop pairs) current-beg (car pair) - current-len (cdr pair) + current-end (cdr pair) current-buf (marker-buffer current-beg)) (pop-to-buffer current-buf) (goto-char current-beg) - (when (re-search-forward from (+ current-beg current-len) noerror) + (when (re-search-forward from current-end noerror) (setq found t))) found)))) ;; FIXME: Despite this being a multi-buffer replacement, `N' @@ -870,7 +886,7 @@ IGNORES is a list of glob patterns." hits))) (unwind-protect (cl-mapcan (lambda (hit) (xref--collect-matches hit regexp)) - (nreverse hits)) + hits) ;; TODO: Same as above. (mapc #'kill-buffer (cl-set-difference (buffer-list) orig-buffers))))) |