diff options
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/artist.el | 122 | ||||
-rw-r--r-- | lisp/textmodes/bibtex.el | 356 | ||||
-rw-r--r-- | lisp/textmodes/conf-mode.el | 191 | ||||
-rw-r--r-- | lisp/textmodes/css-mode.el | 83 | ||||
-rw-r--r-- | lisp/textmodes/flyspell.el | 137 | ||||
-rw-r--r-- | lisp/textmodes/ispell.el | 197 | ||||
-rw-r--r-- | lisp/textmodes/mhtml-mode.el | 97 | ||||
-rw-r--r-- | lisp/textmodes/nroff-mode.el | 1 | ||||
-rw-r--r-- | lisp/textmodes/page-ext.el | 21 | ||||
-rw-r--r-- | lisp/textmodes/paragraphs.el | 65 | ||||
-rw-r--r-- | lisp/textmodes/picture.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/po.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/refer.el | 12 | ||||
-rw-r--r-- | lisp/textmodes/reftex-ref.el | 4 | ||||
-rw-r--r-- | lisp/textmodes/reftex-vars.el | 4 | ||||
-rw-r--r-- | lisp/textmodes/reftex.el | 2 | ||||
-rw-r--r-- | lisp/textmodes/remember.el | 6 | ||||
-rw-r--r-- | lisp/textmodes/rst.el | 20 | ||||
-rw-r--r-- | lisp/textmodes/sgml-mode.el | 37 | ||||
-rw-r--r-- | lisp/textmodes/table.el | 55 | ||||
-rw-r--r-- | lisp/textmodes/tex-mode.el | 75 | ||||
-rw-r--r-- | lisp/textmodes/texinfo.el | 84 | ||||
-rw-r--r-- | lisp/textmodes/tildify.el | 4 |
23 files changed, 824 insertions, 753 deletions
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index eb07bb4d910..90e8d360c1b 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -1,10 +1,10 @@ -;;; artist.el --- draw ascii graphics with your mouse +;;; artist.el --- draw ascii graphics with your mouse -*- lexical-binding: t -*- ;; Copyright (C) 2000-2020 Free Software Foundation, Inc. ;; Author: Tomas Abrahamsson <tab@lysator.liu.se> ;; Keywords: mouse -;; Version: 1.2.6 +;; Old-Version: 1.2.6 ;; Release-date: 6-Aug-2004 ;; Location: http://www.lysator.liu.se/~tab/artist/ @@ -115,8 +115,6 @@ ;;; Requirements: -;; Artist requires Emacs 19.28 or higher. -;; ;; Artist requires the `rect' package (which comes with Emacs) to be ;; loadable, unless the variable `artist-interface-with-rect' is set ;; to nil. @@ -127,9 +125,6 @@ ;;; Known bugs: -;; The shifted operations are not available when drawing with the mouse -;; in Emacs 19.29 and 19.30. -;; ;; It is not possible to change between shifted and unshifted operation ;; while drawing with the mouse. (See the comment in the function ;; artist-shift-has-changed for further details.) @@ -1849,9 +1844,7 @@ Return a list (RETURN-CODE STDOUT STDERR)." nil)) (tmp-stdout-buffer (get-buffer-create (concat "*artist-" program "*"))) - (tmp-stderr-file-name (make-temp-file "artist-stdout.")) - (binary-process-input nil) ; for msdos - (binary-process-output nil)) + (tmp-stderr-file-name (make-temp-file "artist-stdout."))) ;; Prepare stdin (if stdin (artist-string-to-file stdin tmp-stdin-file-name)) @@ -1999,25 +1992,11 @@ The replacement is used to convert tabs and new-lines to spaces." (defun artist-replace-chars (new-char count) "Replace characters at point with NEW-CHAR. COUNT chars are replaced." - ;; Check that the variable exists first. The doc says it was added in 19.23. - (if (and (and (boundp 'emacs-major-version) (= emacs-major-version 20)) - (and (boundp 'emacs-minor-version) (<= emacs-minor-version 3))) - ;; This is a bug workaround for Emacs 20, versions up to 20.3: - ;; The self-insert-command doesn't care about the overwrite-mode, - ;; so the insertion is done in the same way as in picture mode. - ;; This seems to be a little bit slower. - (let* ((replaced-c (artist-get-replacement-char new-char)) - (replaced-s (make-string count replaced-c))) - (artist-move-to-xy (+ (artist-current-column) count) - (artist-current-line)) - (delete-char (- count)) - (insert replaced-s)) - ;; In emacs-19, the self-insert-command works better - (let ((overwrite-mode 'overwrite-mode-textual) - (fill-column 32765) ; Large :-) - (blink-matching-paren nil)) - (setq last-command-event (artist-get-replacement-char new-char)) - (self-insert-command count)))) + (let ((overwrite-mode 'overwrite-mode-textual) + (fill-column 32765) ; Large :-) + (blink-matching-paren nil)) + (setq last-command-event (artist-get-replacement-char new-char)) + (self-insert-command count))) (defsubst artist-replace-string (string &optional see-thru) "Replace contents at point with STRING. @@ -2740,7 +2719,7 @@ SHAPE-INFO is a list of four straight lines." ;; Filling rectangles and squares ;; -(defun artist-fill-rect (rect x1 y1 x2 y2) +(defun artist-fill-rect (_rect x1 y1 x2 y2) "Fill rectangle RECT from X1,Y1 to X2,Y2." (let ((x (1+ (min x1 x2))) (y (1+ (min y1 y2))) @@ -2752,7 +2731,7 @@ SHAPE-INFO is a list of four straight lines." (artist-replace-chars artist-fill-char w) (setq y (1+ y)))))) -(defun artist-fill-square (square x1 y1 x2 y2) +(defun artist-fill-square (_square x1 y1 x2 y2) "Fill a SQUARE from X1,Y1 to X2,Y2." (let* ((square-corners (artist-rect-corners-squarify x1 y1 x2 y2)) (new-x1 (elt square-corners 0)) @@ -2814,7 +2793,7 @@ to append to the end of the list, when doing free-hand drawing)." (setq artist-key-poly-point-list (list (cons x1 y1)))) -(defun artist-pen-set-arrow-points (x1 y1) +(defun artist-pen-set-arrow-points (_x1 _y1) "Set arrow points for pen drawing using X1, Y1. Also, the `artist-key-poly-point-list' is reversed." @@ -3015,11 +2994,11 @@ Returns a list of points. Each point is on the form (X1 . Y1)." ;; Step to next spray point (setq spray-points (cdr spray-points))))) -(defun artist-spray-clear-circle (circle x1 y1 x2 y2) +(defun artist-spray-clear-circle (circle _x1 _y1 _x2 _y2) "Clear circle CIRCLE at X1, Y1 through X2, Y2." (artist-undraw-circle circle)) -(defun artist-spray-set-radius (circle x1 y1 x2 y2) +(defun artist-spray-set-radius (_circle x1 y1 x2 y2) "Set spray radius from CIRCLE at X1, Y1 through X2, Y2." (let ((dx (- x2 x1)) (dy (- y2 y1))) @@ -3512,8 +3491,7 @@ POINT-LIST is a list of vectors on the form [X Y SAVED-CHAR NEW-CHAR]. FILL-INFO is a list of vectors on the form [X Y ELLIPSE-WIDTH-ON-THIS-LINE]. The Y-RADIUS must be 0, but the X-RADIUS must not be 0." - (let ((point-list nil) - (width (max (- (abs (* 2 x-radius)) 1))) + (let ((width (max (- (abs (* 2 x-radius)) 1))) (left-edge (1+ (- x1 (abs x-radius)))) (line-char (if artist-line-char-set artist-line-char ?-)) (i 0) @@ -3621,7 +3599,7 @@ FILL-INFO is a list of vectors on the form [X Y ELLIPSE-WIDTH-ON-THIS-LINE]." ; ; Filling ellipses ; -(defun artist-fill-ellipse (ellipse x y x-radius y-radius) +(defun artist-fill-ellipse (ellipse _x _y _x-radius _y-radius) "Fill an ELLIPSE centered at X,Y with radius X-RADIUS and Y-RADIUS." (let ((fill-info (aref (artist-2point-get-shapeinfo ellipse) 1))) (mapcar @@ -3741,11 +3719,11 @@ original contents of that area in the buffer." (setq x (1+ x))) last-x))) -(defun artist-ff-is-topmost-line (x y) +(defun artist-ff-is-topmost-line (_x y) "Determine whether the position X,Y is on the topmost line or not." (= y 0)) -(defun artist-ff-is-bottommost-line (x y) +(defun artist-ff-is-bottommost-line (_x y) "Determine whether the position X,Y is on the bottommost line or not." (save-excursion (goto-char (point-max)) @@ -3761,7 +3739,6 @@ original contents of that area in the buffer." (defun artist-flood-fill (x1 y1) "Flood-fill starting at X1, Y1. Fill with the char in `artist-fill-char'." (let ((stack nil) - (input-queue nil) ;; We are flood-filling the area that has this character. (c (artist-get-char-at-xy-conv x1 y1)) (artist-fill-char (if artist-fill-char-set @@ -3903,7 +3880,7 @@ Optional argument STATE can be used to set state (default is nil)." (setq artist-arrow-point-2 (artist-make-arrow-point xn yn dirn)))) -(defun artist-set-arrow-points-for-2points (shape x1 y1 x2 y2) +(defun artist-set-arrow-points-for-2points (shape _x1 _y1 _x2 _y2) "Generic function for setting arrow-points for 2-point shapes. The 2-point shape SHAPE is drawn from X1, Y1 to X2, Y2." (let* ((endpoint1 (artist-2point-get-endpoint1 shape)) @@ -3925,28 +3902,24 @@ The 2-point shape SHAPE is drawn from X1, Y1 to X2, Y2." ;; on the draw-how ;; -(defun artist-key-undraw-continously (x y) +(defun artist-key-undraw-continously (_x _y) "Undraw current continuous shape with point at X, Y." ;; No undraw-info for continuous shapes nil) -(defun artist-key-undraw-poly (x y) +(defun artist-key-undraw-poly (_x _y) "Undraw current poly shape with point at X, Y." - (let ((undraw-fn (artist-go-get-undraw-fn-from-symbol artist-curr-go)) - (x1 (artist-endpoint-get-x artist-key-endpoint1)) - (y1 (artist-endpoint-get-y artist-key-endpoint1))) + (let ((undraw-fn (artist-go-get-undraw-fn-from-symbol artist-curr-go))) (artist-funcall undraw-fn artist-key-shape))) -(defun artist-key-undraw-1point (x y) +(defun artist-key-undraw-1point (_x _y) "Undraw current 1-point shape at X, Y." ;; No undraw-info for 1-point shapes nil) -(defun artist-key-undraw-2points (x y) +(defun artist-key-undraw-2points (_x _y) "Undraw current 2-point shape at X, Y." - (let ((undraw-fn (artist-go-get-undraw-fn-from-symbol artist-curr-go)) - (x1 (artist-endpoint-get-x artist-key-endpoint1)) - (y1 (artist-endpoint-get-y artist-key-endpoint1))) + (let ((undraw-fn (artist-go-get-undraw-fn-from-symbol artist-curr-go))) (artist-funcall undraw-fn artist-key-shape))) (defun artist-key-undraw-common () @@ -4090,7 +4063,7 @@ Trimming here means removing white space at end of a line." (setq artist-key-shape (artist-funcall draw-fn x1 y1 x2 y2)))))) -(defun artist-key-do-continously-1point (x y) +(defun artist-key-do-continously-1point (_x _y) "Update current 1-point shape at X,Y." ;; Nothing to do continuously for operations ;; where we have only one input point @@ -4290,8 +4263,7 @@ If optional argument THIS-IS-LAST-POINT is non-nil, this point is the last." (defun artist-key-set-point-1point (x y) "Set point for current 1-point shape at X,Y." - (let ((draw-fn (artist-go-get-draw-fn-from-symbol artist-curr-go)) - (init-fn (artist-go-get-init-fn-from-symbol artist-curr-go)) + (let ((init-fn (artist-go-get-init-fn-from-symbol artist-curr-go)) (prep-fill-fn (artist-go-get-prep-fill-fn-from-symbol artist-curr-go)) (exit-fn (artist-go-get-exit-fn-from-symbol artist-curr-go)) (draw-fn (artist-go-get-draw-fn-from-symbol artist-curr-go)) @@ -4821,7 +4793,7 @@ If optional argument STATE is positive, turn borders on." (orig-draw-region-min-y artist-draw-region-min-y) (orig-draw-region-max-y artist-draw-region-max-y) (orig-pointer-shape (if (eq window-system 'x) x-pointer-shape nil)) - (echoq-keystrokes 10000) ; a lot of seconds + (echo-keystrokes 0) ; Don't echo unfinished commands. ;; Remember original binding for the button-up event to this ;; button-down event. (key (artist-compute-up-event-key ev)) @@ -4937,7 +4909,7 @@ If optional argument STATE is positive, turn borders on." ;; Mouse routines ;; -(defsubst artist-shift-has-changed (shift-state ev) +(defsubst artist-shift-has-changed (_shift-state _ev) "From the last SHIFT-STATE and EV, determine if the shift-state has changed." ;; This one simply doesn't work. ;; @@ -4962,6 +4934,12 @@ If optional argument STATE is positive, turn borders on." (cons (+ window-x window-start-x) (+ window-y window-start-y)))) +(defun artist--adjust-x (x) + "Adjust the X position wrt. `display-line-numbers-mode'." + (let ((adjust (line-number-display-width))) + (if (= adjust 0) + x + (- x adjust 2)))) (defun artist-mouse-draw-continously (ev) "Generic function for shapes that require 1 point as input. @@ -4983,10 +4961,9 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos)) - (shape) - (timer)) + (timer nil)) (select-window (posn-window ev-start)) (artist-funcall init-fn x1 y1) (if (not artist-rubber-banding) @@ -5000,7 +4977,7 @@ The event, EV, is the mouse event." (member 'down (event-modifiers ev))) (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x1 (car ev-start-pos)) + (setq x1 (artist--adjust-x (car ev-start-pos))) (setq y1 (cdr ev-start-pos)) ;; Cancel previous timer @@ -5030,7 +5007,7 @@ The event, EV, is the mouse event." (setq draw-fn (artist-go-get-draw-fn-from-symbol op)))) ;; Draw the new shape - (setq shape (artist-funcall draw-fn x1 y1)) + (artist-funcall draw-fn x1 y1) (artist-move-to-xy x1 y1) ;; Start the timer to call `draw-fn' repeatedly every @@ -5080,7 +5057,7 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1-last (car ev-start-pos)) + (x1-last (artist--adjust-x (car ev-start-pos))) (y1-last (cdr ev-start-pos)) (x2 x1-last) (y2 y1-last) @@ -5172,7 +5149,7 @@ The event, EV, is the mouse event." ;; (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) ;; Draw the new shape (if not rubber-banding, place both marks) @@ -5199,7 +5176,7 @@ The event, EV, is the mouse event." ;; set x2 and y2 (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) ;; First undraw last shape @@ -5275,7 +5252,6 @@ Operation is done once. The event, EV, is the mouse event." (shifted (artist-go-get-symbol-shift artist-curr-go t)) (shift-state (artist-event-is-shifted ev)) (op (if shift-state shifted unshifted)) - (draw-how (artist-go-get-draw-how-from-symbol op)) (init-fn (artist-go-get-init-fn-from-symbol op)) (prep-fill-fn (artist-go-get-prep-fill-fn-from-symbol op)) (exit-fn (artist-go-get-exit-fn-from-symbol op)) @@ -5284,7 +5260,7 @@ Operation is done once. The event, EV, is the mouse event." (arrow-set-fn (artist-go-get-arrow-set-fn-from-symbol op)) (ev-start (event-start ev)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos))) (select-window (posn-window ev-start)) (artist-funcall init-fn x1 y1) @@ -5318,7 +5294,7 @@ The event, EV, is the mouse event." (ev-start (event-start ev)) (initial-win (posn-window ev-start)) (ev-start-pos (artist-coord-win-to-buf (posn-col-row ev-start))) - (x1 (car ev-start-pos)) + (x1 (artist--adjust-x (car ev-start-pos))) (y1 (cdr ev-start-pos)) (x2) (y2) @@ -5332,7 +5308,7 @@ The event, EV, is the mouse event." (member 'down (event-modifiers ev))) (setq ev-start-pos (artist-coord-win-to-buf (posn-col-row (event-start ev)))) - (setq x2 (car ev-start-pos)) + (setq x2 (artist--adjust-x (car ev-start-pos))) (setq y2 (cdr ev-start-pos)) (if (not (eq initial-win (posn-window (event-start ev)))) @@ -5407,8 +5383,7 @@ The event, EV, is the mouse event." (interactive) (require 'reporter) (if (y-or-n-p "Do you want to submit a bug report on Artist? ") - (let ((to artist-maintainer-address) - (vars '(window-system + (let ((vars '(window-system window-system-version ;; artist-rubber-banding @@ -5423,10 +5398,9 @@ The event, EV, is the mouse event." artist-arrow-point-2))) ;; Remove those variables from vars that are not bound (mapc - (function - (lambda (x) - (if (not (and (boundp x) (symbol-value x))) - (setq vars (delq x vars))))) vars) + (lambda (x) + (if (not (and (boundp x) (symbol-value x))) + (setq vars (delq x vars)))) vars) (reporter-submit-bug-report artist-maintainer-address (concat "artist.el " artist-version) diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 670e763814c..fcf63ed5ecf 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -85,8 +85,8 @@ If this is a function, call it to generate the initial field text." :type '(choice (const :tag "None" nil) (string :tag "Initial text") (function :tag "Initialize Function") - (const :tag "Default" t))) -(put 'bibtex-include-OPTkey 'risky-local-variable t) + (const :tag "Default" t)) + :risky t) (defcustom bibtex-user-optional-fields '(("annote" "Personal annotation (ignored)")) @@ -97,8 +97,8 @@ in `bibtex-BibTeX-entry-alist' (which see)." :type '(repeat (group (string :tag "Field") (string :tag "Comment") (option (choice :tag "Init" - (const nil) string function))))) -(put 'bibtex-user-optional-fields 'risky-local-variable t) + (const nil) string function)))) + :risky t) (defcustom bibtex-entry-format '(opts-or-alts required-fields numerical-fields) @@ -148,20 +148,18 @@ The value nil means do no formatting at all." (const unify-case) (const braces) (const strings) - (const sort-fields)))) -(put 'bibtex-entry-format 'safe-local-variable - (lambda (x) - (or (eq x t) - (let ((OK t)) - (while (consp x) - (unless (memq (pop x) - '(opts-or-alts required-fields numerical-fields - page-dashes whitespace inherit-booktitle realign - last-comma delimiters unify-case braces strings - sort-fields)) - (setq OK nil))) - (unless (null x) (setq OK nil)) - OK)))) + (const sort-fields))) + :safe (lambda (x) + (or (eq x t) + (let ((ok t)) + (while (consp x) + (unless (memq (pop x) + '( opts-or-alts required-fields numerical-fields + page-dashes whitespace inherit-booktitle + realign last-comma delimiters unify-case + braces strings sort-fields )) + (setq ok nil))) + (unless x ok))))) (defcustom bibtex-field-braces-alist nil "Alist of field regexps that \\[bibtex-clean-entry] encloses by braces. @@ -207,9 +205,8 @@ See also `bibtex-sort-ignore-string-entries'." (const plain) (const crossref) (const entry-class) - (const t))) -(put 'bibtex-maintain-sorted-entries 'safe-local-variable - (lambda (a) (memq a '(nil t plain crossref entry-class)))) + (const t)) + :safe (lambda (a) (memq a '(nil t plain crossref entry-class)))) (defcustom bibtex-sort-entry-class '(("String") @@ -223,18 +220,17 @@ to all entries not explicitly mentioned." :group 'bibtex :type '(repeat (choice :tag "Class" (const :tag "catch-all" (catch-all)) - (repeat :tag "Entry type" string)))) -(put 'bibtex-sort-entry-class 'safe-local-variable - (lambda (x) (let ((OK t)) - (while (consp x) - (let ((y (pop x))) - (while (consp y) - (let ((z (pop y))) - (unless (or (stringp z) (eq z 'catch-all)) - (setq OK nil)))) - (unless (null y) (setq OK nil)))) - (unless (null x) (setq OK nil)) - OK))) + (repeat :tag "Entry type" string))) + :safe (lambda (x) + (let ((ok t)) + (while (consp x) + (let ((y (pop x))) + (while (consp y) + (let ((z (pop y))) + (unless (or (stringp z) (eq z 'catch-all)) + (setq ok nil)))) + (when y (setq ok nil)))) + (unless x ok)))) (defcustom bibtex-sort-ignore-string-entries t "If non-nil, BibTeX @String entries are not sort-significant. @@ -391,13 +387,13 @@ If parsing fails, try to set this variable to nil." (("author") ("howpublished" "The way in which the booklet was published") ("address") ("month") ("year") ("note"))) - ("PhdThesis" "PhD. Thesis" + ("PhdThesis" "PhD Thesis" (("author") - ("title" "Title of the PhD. thesis") - ("school" "School where the PhD. thesis was written") + ("title" "Title of the PhD thesis") + ("school" "School where the PhD thesis was written") ("year")) nil - (("type" "Type of the PhD. thesis") + (("type" "Type of the PhD thesis") ("address" "Address of the school (if not part of field \"school\") or country") ("month") ("note"))) ("MastersThesis" "Master's Thesis" @@ -440,7 +436,7 @@ If parsing fails, try to set this variable to nil." "Alist of BibTeX entry types and their associated fields. Elements are lists (ENTRY-TYPE DOC REQUIRED CROSSREF OPTIONAL). ENTRY-TYPE is the type of a BibTeX entry. -DOC is a brief doc string used for menus. If nil ENTRY-TYPE is used. +DOC is a brief doc string used for menus. If nil ENTRY-TYPE is used. REQUIRED is a list of required fields. CROSSREF is a list of fields that are optional if a crossref field is present; but these fields are required otherwise. @@ -459,8 +455,8 @@ ALTERNATIVE if non-nil is an integer that numbers sets of alternatives, starting from zero." :group 'bibtex :version "26.1" ; add Conference - :type 'bibtex-entry-alist) -(put 'bibtex-BibTeX-entry-alist 'risky-local-variable t) + :type 'bibtex-entry-alist + :risky t) (defcustom bibtex-biblatex-entry-alist ;; Compare in biblatex documentation: @@ -471,8 +467,8 @@ alternatives, starting from zero." ("year" nil nil 0) ("date" nil nil 0)) nil (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon") - ("editor") ("editora") ("editorb") ("editorc") - ("journalsubtitle") ("issuetitle") ("issuesubtitle") + ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle") + ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon") ("language") ("origlanguage") ("series") ("volume") ("number") ("eid") ("issue") ("month") ("pages") ("version") ("note") ("issn") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") @@ -485,7 +481,7 @@ alternatives, starting from zero." ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") - ("series") ("number") ("note") ("publisher") ("location") ("isbn") + ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("MVBook" "Multi-Volume Book" @@ -506,7 +502,7 @@ alternatives, starting from zero." ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") - ("series") ("number") ("note") ("publisher") ("location") ("isbn") + ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("BookInBook" "Book in Collection" ; same as @inbook @@ -517,7 +513,7 @@ alternatives, starting from zero." ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") - ("series") ("number") ("note") ("publisher") ("location") ("isbn") + ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("SuppBook" "Supplemental Material in a Book" ; same as @inbook @@ -528,7 +524,7 @@ alternatives, starting from zero." ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") - ("series") ("number") ("note") ("publisher") ("location") ("isbn") + ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Booklet" "Booklet (Bound, but no Publisher)" @@ -536,9 +532,9 @@ alternatives, starting from zero." ("year" nil nil 1) ("date" nil nil 1)) nil (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") - ("note") ("location") ("chapter") ("pages") ("pagetotal") ("addendum") - ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") - ("url") ("urldate"))) + ("note") ("location") ("eid") ("chapter") ("pages") ("pagetotal") + ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") + ("eprinttype") ("url") ("urldate"))) ("Collection" "Single-Volume Collection" (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) nil @@ -547,8 +543,8 @@ alternatives, starting from zero." ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") ("series") ("number") ("note") - ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal") - ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") + ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") + ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("MVCollection" "Multi-Volume Collection" (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) @@ -562,32 +558,40 @@ alternatives, starting from zero." ("InCollection" "Article in a Collection" (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) (("booktitle")) - (("editor") ("editora") ("editorb") ("editorc") ("translator") ("annotator") - ("commentator") ("introduction") ("foreword") ("afterword") + (("editor") ("editora") ("editorb") ("editorc") ("translator") + ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") ("series") ("number") ("note") ("publisher") ("location") - ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") + ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("SuppCollection" "Supplemental Material in a Collection" ; same as @incollection - (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) + (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) (("booktitle")) - (("editora") ("editorb") ("editorc") ("translator") ("annotator") - ("commentator") ("introduction") ("foreword") ("afterword") + (("editor") ("editora") ("editorb") ("editorc") ("translator") + ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") ("series") ("number") ("note") ("publisher") ("location") - ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") + ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) + ("Dataset" "Data Set" + (("author" nil nil 0) ("editor" nil nil 0) ("title") + ("year" nil nil 1) ("date" nil nil 1)) + nil + (("subtitle") ("titleaddon") ("language") ("edition") ("type") ("series") + ("number") ("version") ("note") ("organization") ("publisher") + ("location") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") + ("eprinttype") ("url") ("urldate"))) ("Manual" "Technical Manual" (("author" nil nil 0) ("editor" nil nil 0) ("title") ("year" nil nil 1) ("date" nil nil 1)) nil (("subtitle") ("titleaddon") ("language") ("edition") ("type") ("series") ("number") ("version") ("note") - ("organization") ("publisher") ("location") ("isbn") ("chapter") + ("organization") ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Misc" "Miscellaneous" @@ -596,35 +600,37 @@ alternatives, starting from zero." nil (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") ("version") ("note") ("organization") ("location") - ("date") ("month") ("year") ("addendum") ("pubstate") + ("month") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Online" "Online Resource" (("author" nil nil 0) ("editor" nil nil 0) ("title") - ("year" nil nil 1) ("date" nil nil 1) ("url")) + ("year" nil nil 1) ("date" nil nil 1) + ("doi" nil nil 2) ("eprint" nil nil 2) ("url" nil nil 2)) nil (("subtitle") ("titleaddon") ("language") ("version") ("note") - ("organization") ("date") ("month") ("year") ("addendum") - ("pubstate") ("urldate"))) + ("organization") ("month") ("addendum") + ("pubstate") ("eprintclass") ("eprinttype") ("urldate"))) ("Patent" "Patent" (("author") ("title") ("number") ("year" nil nil 0) ("date" nil nil 0)) nil (("holder") ("subtitle") ("titleaddon") ("type") ("version") ("location") - ("note") ("date") ("month") ("year") ("addendum") ("pubstate") + ("note") ("month") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Periodical" "Complete Issue of a Periodical" (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) nil - (("editora") ("editorb") ("editorc") ("subtitle") ("issuetitle") - ("issuesubtitle") ("language") ("series") ("volume") ("number") ("issue") - ("date") ("month") ("year") ("note") ("issn") ("addendum") ("pubstate") + (("editora") ("editorb") ("editorc") ("subtitle") ("titleaddon") + ("issuetitle") ("issuesubtitle") ("issuetitleaddon") ("language") + ("series") ("volume") ("number") ("issue") + ("month") ("note") ("issn") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("SuppPeriodical" "Supplemental Material in a Periodical" ; same as @article (("author") ("title") ("journaltitle") ("year" nil nil 0) ("date" nil nil 0)) nil (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon") - ("editor") ("editora") ("editorb") ("editorc") - ("journalsubtitle") ("issuetitle") ("issuesubtitle") + ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle") + ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon") ("language") ("origlanguage") ("series") ("volume") ("number") ("eid") ("issue") ("month") ("pages") ("version") ("note") ("issn") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") @@ -632,19 +638,19 @@ alternatives, starting from zero." ("Proceedings" "Single-Volume Conference Proceedings" (("title") ("year" nil nil 0) ("date" nil nil 0)) nil - (("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") - ("maintitleaddon") ("eventtitle") ("eventdate") ("venue") ("language") - ("editor") - ("volume") ("part") ("volumes") ("series") ("number") ("note") - ("organization") ("publisher") ("location") ("month") - ("isbn") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") - ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) + (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") + ("maintitleaddon") ("eventtitle") ("eventtitleaddon") ("eventdate") + ("venue") ("language") ("volume") ("part") ("volumes") ("series") + ("number") ("note") ("organization") ("publisher") ("location") ("month") + ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum") + ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") + ("urldate"))) ("MVProceedings" "Multi-Volume Conference Proceedings" - (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) + (("title") ("year" nil nil 0) ("date" nil nil 0)) nil - (("subtitle") ("titleaddon") ("eventtitle") ("eventdate") ("venue") - ("language") ("volumes") ("series") ("number") ("note") - ("organization") ("publisher") ("location") ("month") + (("editor") ("subtitle") ("titleaddon") ("eventtitle") ("eventtitleaddon") + ("eventdate") ("venue") ("language") ("volumes") ("series") ("number") + ("note") ("organization") ("publisher") ("location") ("month") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("InProceedings" "Article in Conference Proceedings" @@ -652,9 +658,9 @@ alternatives, starting from zero." (("booktitle")) (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") - ("eventtitle") ("eventdate") ("venue") ("language") + ("eventtitle") ("eventtitleaddon") ("eventdate") ("venue") ("language") ("volume") ("part") ("volumes") ("series") ("number") ("note") - ("organization") ("publisher") ("location") ("month") ("isbn") + ("organization") ("publisher") ("location") ("month") ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Reference" "Single-Volume Work of Reference" ; same as @collection @@ -665,8 +671,8 @@ alternatives, starting from zero." ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") ("series") ("number") ("note") - ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal") - ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") + ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") + ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("MVReference" "Multi-Volume Work of Reference" ; same as @mvcollection (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) @@ -678,44 +684,53 @@ alternatives, starting from zero." ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("InReference" "Article in a Work of Reference" ; same as @incollection - (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) + (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) (("booktitle")) - (("editora") ("editorb") ("editorc") ("translator") ("annotator") - ("commentator") ("introduction") ("foreword") ("afterword") + (("editor") ("editora") ("editorb") ("editorc") ("translator") + ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") ("maintitleaddon") ("booksubtitle") ("booktitleaddon") ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") ("series") ("number") ("note") ("publisher") ("location") - ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") + ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Report" "Technical or Research Report" (("author") ("title") ("type") ("institution") ("year" nil nil 0) ("date" nil nil 0)) nil (("subtitle") ("titleaddon") ("language") ("number") ("version") ("note") - ("location") ("month") ("isrn") ("chapter") ("pages") ("pagetotal") - ("addendum") ("pubstate") + ("location") ("month") ("isrn") ("eid") ("chapter") ("pages") + ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) - ("Thesis" "PhD. or Master's Thesis" + ("Software" "Computer Software" ; Same as @misc. + (("author" nil nil 0) ("editor" nil nil 0) ("title") + ("year" nil nil 1) ("date" nil nil 1)) + nil + (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") + ("version") ("note") ("organization") ("location") + ("month") ("addendum") ("pubstate") + ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) + ("Thesis" "PhD or Master's Thesis" (("author") ("title") ("type") ("institution") ("year" nil nil 0) ("date" nil nil 0)) nil (("subtitle") ("titleaddon") ("language") ("note") ("location") - ("month") ("isbn") ("chapter") ("pages") ("pagetotal") + ("month") ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) ("Unpublished" "Unpublished" (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) nil - (("subtitle") ("titleaddon") ("language") ("howpublished") - ("note") ("location") ("isbn") ("date") ("month") ("year") - ("addendum") ("pubstate") ("url") ("urldate")))) + (("subtitle") ("titleaddon") ("type") ("eventtitle") ("eventtitleaddon") + ("eventdate") ("venue") ("language") ("howpublished") ("note") + ("location") ("isbn") ("month") ("addendum") ("pubstate") ("doi") + ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))) "Alist of biblatex entry types and their associated fields. It has the same format as `bibtex-BibTeX-entry-alist'." :group 'bibtex - :version "24.1" - :type 'bibtex-entry-alist) -(put 'bibtex-biblatex-entry-alist 'risky-local-variable t) + :version "28.1" + :type 'bibtex-entry-alist + :risky t) (define-widget 'bibtex-field-alist 'lazy "Format of `bibtex-BibTeX-entry-alist' and friends." @@ -770,6 +785,7 @@ if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD." ("eprinttype" "Type of eprint identifier") ("eventdate" "Date of a conference or some other event") ("eventtitle" "Title of a conference or some other event") + ("eventtitleaddon" "Annex to the eventtitle (e.g., acronym of known event)") ("file" "Local link to an electronic version of the work") ("foreword" "Author(s) of a foreword to the work") ("holder" "Holder(s) of a patent") @@ -785,9 +801,11 @@ if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD." ("issue" "Issue of a journal") ("issuesubtitle" "Subtitle of a specific issue of a journal or other periodical.") ("issuetitle" "Title of a specific issue of a journal or other periodical.") + ("issuetitleaddon" "Annex to the issuetitle") ("iswc" "International Standard Work Code of a musical work") ("journalsubtitle" "Subtitle of a journal, a newspaper, or some other periodical.") ("journaltitle" "Name of a journal, a newspaper, or some other periodical.") + ("journaltitleaddon" "Annex to the journaltitle") ("label" "Substitute for the regular label to be used by the citation style") ("language" "Language(s) of the work") ("library" "Library name and a call number") @@ -815,6 +833,8 @@ if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD." ("series" "Name of a publication series") ("shortauthor" "Author(s) of the work, given in an abbreviated form") ("shorteditor" "Editor(s) of the work, given in an abbreviated form") + ("shorthand" "Special designation overriding the default label") + ("shorthandintro" "Phrase overriding the standard shorthand introduction") ("shortjournal" "Short version or an acronym of the journal title") ("shortseries" "Short version or an acronym of the series field") ("shorttitle" "Title in an abridged form") @@ -833,7 +853,7 @@ if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD." "Alist of biblatex fields. It has the same format as `bibtex-BibTeX-entry-alist'." :group 'bibtex - :version "24.1" + :version "28.1" :type 'bibtex-field-alist) (defcustom bibtex-dialect-list '(BibTeX biblatex) @@ -850,15 +870,15 @@ Predefined dialects include BibTeX and biblatex." To interactively change the dialect use the command `bibtex-set-dialect'." :group 'bibtex :version "24.1" - :set '(lambda (symbol value) - (set-default symbol value) - ;; `bibtex-set-dialect' is undefined during loading (no problem) - (if (fboundp 'bibtex-set-dialect) - (bibtex-set-dialect value))) + :set (lambda (symbol value) + (set-default symbol value) + ;; `bibtex-set-dialect' is undefined during loading (no problem). + (if (fboundp 'bibtex-set-dialect) + (bibtex-set-dialect value))) :type '(choice (const BibTeX) (const biblatex) - (symbol :tag "Custom"))) -(put 'bibtex-dialect 'safe-local-variable 'symbolp) + (symbol :tag "Custom")) + :safe #'symbolp) (defcustom bibtex-no-opt-remove-re "\\`option" "If a field name matches this regexp, the prefix OPT is not removed. @@ -1051,7 +1071,7 @@ See `bibtex-generate-autokey' for details." (defvaralias 'bibtex-autokey-name-case-convert 'bibtex-autokey-name-case-convert-function) -(defcustom bibtex-autokey-name-case-convert-function 'downcase +(defcustom bibtex-autokey-name-case-convert-function #'downcase "Function called for each name to perform case conversion. See `bibtex-generate-autokey' for details." :group 'bibtex-autokey @@ -1059,9 +1079,8 @@ See `bibtex-generate-autokey' for details." (const :tag "Downcase" downcase) (const :tag "Capitalize" capitalize) (const :tag "Upcase" upcase) - (function :tag "Conversion function"))) -(put 'bibtex-autokey-name-case-convert-function 'safe-local-variable - (lambda (x) (memq x '(upcase downcase capitalize identity)))) + (function :tag "Conversion function" :value identity)) + :safe (lambda (x) (memq x '(upcase downcase capitalize identity)))) (defcustom bibtex-autokey-name-length 'infty "Number of characters from name to incorporate into key. @@ -1127,7 +1146,7 @@ Case is significant. See `bibtex-generate-autokey' for details." (defvaralias 'bibtex-autokey-titleword-case-convert 'bibtex-autokey-titleword-case-convert-function) -(defcustom bibtex-autokey-titleword-case-convert-function 'downcase +(defcustom bibtex-autokey-titleword-case-convert-function #'downcase "Function called for each titleword to perform case conversion. See `bibtex-generate-autokey' for details." :group 'bibtex-autokey @@ -1188,12 +1207,13 @@ See `bibtex-generate-autokey' for details." :group 'bibtex-autokey :type 'boolean) -(defcustom bibtex-autokey-before-presentation-function nil - "If non-nil, function to call before generated key is presented. +(defcustom bibtex-autokey-before-presentation-function #'identity + "Function to call before generated key is presented. The function must take one argument (the automatically generated key), and must return a string (the key to use)." :group 'bibtex-autokey - :type '(choice (const nil) function)) + :version "28.1" + :type 'function) (defcustom bibtex-entry-offset 0 "Offset for BibTeX entries. @@ -1242,7 +1262,7 @@ If non-nil, the column for the equal sign is the value of :group 'bibtex :type '(repeat string)) -(defcustom bibtex-summary-function 'bibtex-summary +(defcustom bibtex-summary-function #'bibtex-summary "Function to call for generating a summary of current BibTeX entry. It takes no arguments. Point must be at beginning of entry. Used by `bibtex-complete-crossref-cleanup' and `bibtex-copy-summary-as-kill'." @@ -1312,8 +1332,8 @@ The following is a complex example, see URL `http://link.aps.org/'. (regexp :tag "Regexp") (choice (string :tag "Replacement") (integer :tag "Sub-match") - (function :tag "Filter")))))))) -(put 'bibtex-generate-url-list 'risky-local-variable t) + (function :tag "Filter"))))))) + :risky t) (defcustom bibtex-cite-matcher-alist '(("\\\\cite[ \t\n]*{\\([^}]+\\)}" . 1)) @@ -1535,21 +1555,19 @@ At most `bibtex-entry-kill-ring-max' items are kept here.") (defvar bibtex-last-kill-command nil "Type of the last kill command (either `field' or `entry').") -(defvar bibtex-strings +(defvar-local bibtex-strings (lazy-completion-table bibtex-strings (lambda () (bibtex-parse-strings (bibtex-string-files-init)))) "Completion table for BibTeX string keys. Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.") -(make-variable-buffer-local 'bibtex-strings) (put 'bibtex-strings 'risky-local-variable t) -(defvar bibtex-reference-keys +(defvar-local bibtex-reference-keys (lazy-completion-table bibtex-reference-keys (lambda () (bibtex-parse-keys nil t))) "Completion table for BibTeX reference keys. The CDRs of the elements are t for header keys and nil for crossref keys.") -(make-variable-buffer-local 'bibtex-reference-keys) (put 'bibtex-reference-keys 'risky-local-variable t) (defvar bibtex-buffer-last-parsed-tick nil @@ -1660,7 +1678,7 @@ Initialized by `bibtex-set-dialect'.") (defvar bibtex-font-lock-url-regexp ;; Assume that field names begin at the beginning of a line. (concat "^[ \t]*" - (regexp-opt (delete-dups (mapcar 'caar bibtex-generate-url-list)) t) + (regexp-opt (delete-dups (mapcar #'caar bibtex-generate-url-list)) t) "[ \t]*=[ \t]*") "Regexp for `bibtex-font-lock-url' derived from `bibtex-generate-url-list'.") @@ -1892,14 +1910,16 @@ If `bibtex-expand-strings' is non-nil, also expand BibTeX strings." (let ((mtch (match-string-no-properties 0))) (push (or (if bibtex-expand-strings (cdr (assoc-string mtch (bibtex-strings) t))) - mtch) content) + mtch) + content) (goto-char (match-end 0))) (let ((bounds (bibtex-parse-field-string))) (push (buffer-substring-no-properties - (1+ (car bounds)) (1- (cdr bounds))) content) + (1+ (car bounds)) (1- (cdr bounds))) + content) (goto-char (cdr bounds)))) (re-search-forward "\\=[ \t\n]*#[ \t\n]*" nil t)) - (apply 'concat (nreverse content)))) + (apply #'concat (nreverse content)))) (buffer-substring-no-properties (bibtex-start-of-text-in-field bounds) (bibtex-end-of-text-in-field bounds)))) @@ -2239,8 +2259,9 @@ Optional arg BEG is beginning of entry." Optional arg COMMA is as in `bibtex-enclosing-field'." (unless bibtex-last-kill-command (error "BibTeX kill ring is empty")) (let ((fun (lambda (kryp kr) ; adapted from `current-kill' - (car (set kryp (nthcdr (mod (- n (length (eval kryp))) - (length kr)) kr)))))) + (car (set kryp (nthcdr (mod (- n (length (symbol-value kryp))) + (length kr)) + kr)))))) ;; We put the mark at the beginning of the inserted field or entry ;; and point at its end - a behavior similar to what `yank' does. ;; The mark is then used by `bibtex-yank-pop', which needs to know @@ -2251,7 +2272,8 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." (goto-char (bibtex-end-of-field (bibtex-enclosing-field comma))) (push-mark) (bibtex-make-field (funcall fun 'bibtex-field-kill-ring-yank-pointer - bibtex-field-kill-ring) t nil t)) + bibtex-field-kill-ring) + t nil t)) ;; insert past the current entry (bibtex-skip-to-valid-entry) (push-mark) @@ -2615,7 +2637,7 @@ Return optimized value to be used by `bibtex-format-entry'." regexp-alist)) (let (opt-list) ;; Loop over field names - (dolist (field (delete-dups (apply 'append (mapcar 'car regexp-alist)))) + (dolist (field (delete-dups (apply #'append (mapcar #'car regexp-alist)))) (let (rules) ;; Collect all matches we have for this field name (dolist (e regexp-alist) @@ -2623,7 +2645,7 @@ Return optimized value to be used by `bibtex-format-entry'." (push (cons (nth 1 e) (nth 2 e)) rules))) (if (eq type 'braces) ;; concatenate all regexps to a single regexp - (setq rules (concat "\\(?:" (mapconcat 'car rules "\\|") "\\)"))) + (setq rules (concat "\\(?:" (mapconcat #'car rules "\\|") "\\)"))) ;; create list of replacement rules. (push (cons field rules) opt-list))) opt-list)) @@ -2674,7 +2696,7 @@ and `bibtex-autokey-names-stretch'." (if (string= "" names) names (let* ((case-fold-search t) - (name-list (mapcar 'bibtex-autokey-demangle-name + (name-list (mapcar #'bibtex-autokey-demangle-name (split-string names "[ \t\n]+and[ \t\n]+"))) additional-names) (unless (or (not (numberp bibtex-autokey-names)) @@ -2686,7 +2708,7 @@ and `bibtex-autokey-names-stretch'." bibtex-autokey-names) (nreverse name-list))) additional-names bibtex-autokey-additional-names)) - (concat (mapconcat 'identity name-list + (concat (mapconcat #'identity name-list bibtex-autokey-name-separator) additional-names))))) @@ -2736,7 +2758,7 @@ Return the result as a string." ;; specific words and use only a specific amount of words. (let ((counter 0) (ignore-re (concat "\\`\\(?:" - (mapconcat 'identity + (mapconcat #'identity bibtex-autokey-titleword-ignore "\\|") "\\)\\'")) titlewords titlewords-extra word) @@ -2760,7 +2782,7 @@ Return the result as a string." ;; titlewords-extra in titlewords. Otherwise, we ignore titlewords-extra. (unless (string-match "\\b\\w+" titlestring) (setq titlewords (append titlewords-extra titlewords))) - (mapconcat 'bibtex-autokey-demangle-title (nreverse titlewords) + (mapconcat #'bibtex-autokey-demangle-title (nreverse titlewords) bibtex-autokey-titleword-separator)))) (defun bibtex-autokey-demangle-title (titleword) @@ -2837,7 +2859,7 @@ Concatenate the key: non-empty insert `bibtex-autokey-name-year-separator' between the two. If the title part and the year (or name) part are non-empty, insert `bibtex-autokey-year-title-separator' between the two. - 2. If `bibtex-autokey-before-presentation-function' is non-nil, it must be + 2. `bibtex-autokey-before-presentation-function' must be a function taking one argument. Call this function with the generated key as the argument. Use the return value of this function (a string) as the key. @@ -2865,7 +2887,7 @@ Concatenate the key: (defun bibtex-global-key-alist () "Return global key alist based on `bibtex-files'." (if bibtex-files - (apply 'append + (apply #'append (mapcar (lambda (buf) (with-current-buffer buf bibtex-reference-keys)) ;; include current buffer only if it uses `bibtex-mode' @@ -3129,7 +3151,7 @@ does not use `bibtex-mode'." (if buffer-list (switch-to-buffer (completing-read "Switch to BibTeX buffer: " - (mapcar 'buffer-name buffer-list) + (mapcar #'buffer-name buffer-list) nil t (if current (buffer-name (current-buffer))))) (message "No BibTeX buffers defined"))) @@ -3178,7 +3200,7 @@ that is generated by calling `bibtex-url'." Used as default value of `bibtex-summary-function'." ;; It would be neat to make this function customizable. How? (if (looking-at bibtex-entry-maybe-empty-head) - (let* ((bibtex-autokey-name-case-convert-function 'identity) + (let* ((bibtex-autokey-name-case-convert-function #'identity) (bibtex-autokey-name-length 'infty) (bibtex-autokey-names 1) (bibtex-autokey-names-stretch 0) @@ -3189,7 +3211,7 @@ Used as default value of `bibtex-summary-function'." (year (bibtex-autokey-get-year)) (bibtex-autokey-titlewords 5) (bibtex-autokey-titlewords-stretch 2) - (bibtex-autokey-titleword-case-convert-function 'identity) + (bibtex-autokey-titleword-case-convert-function #'identity) (bibtex-autokey-titleword-length 5) (bibtex-autokey-titleword-separator " ") (title (bibtex-autokey-get-title)) @@ -3336,12 +3358,12 @@ BOUND limits the search." (define-button-type 'bibtex-url 'action 'bibtex-button-action - 'bibtex-function 'bibtex-url + 'bibtex-function #'bibtex-url 'help-echo (purecopy "mouse-2, RET: follow URL")) (define-button-type 'bibtex-search-crossref 'action 'bibtex-button-action - 'bibtex-function 'bibtex-search-crossref + 'bibtex-function #'bibtex-search-crossref 'help-echo (purecopy "mouse-2, RET: follow crossref")) (defun bibtex-button (beg end type &rest args) @@ -3405,7 +3427,7 @@ if that value is non-nil. \\{bibtex-mode-map}" (add-hook 'completion-at-point-functions - 'bibtex-completion-at-point-function nil 'local) + #'bibtex-completion-at-point-function nil 'local) (make-local-variable 'bibtex-buffer-last-parsed-tick) ;; Install stealthy parse function if not already installed (unless bibtex-parse-idle-timer @@ -3419,7 +3441,7 @@ if that value is non-nil. (set (make-local-variable 'comment-column) 0) (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[[:alnum:]]+[ \t]*") (set (make-local-variable 'outline-regexp) "[ \t]*@") - (set (make-local-variable 'fill-paragraph-function) 'bibtex-fill-field) + (set (make-local-variable 'fill-paragraph-function) #'bibtex-fill-field) (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset bibtex-contline-indentation) ?\s)) (set (make-local-variable 'font-lock-defaults) @@ -3440,8 +3462,9 @@ if that value is non-nil. (set (make-local-variable 'syntax-propertize-function) (syntax-propertize-via-font-lock bibtex-font-lock-syntactic-keywords)) + (bibtex-set-dialect nil t) ;; Allow `bibtex-dialect' as a file-local variable. - (add-hook 'hack-local-variables-hook 'bibtex-set-dialect nil t)) + (add-hook 'hack-local-variables-hook #'bibtex-set-dialect nil t)) (defun bibtex-entry-alist (dialect) "Return entry-alist for DIALECT." @@ -3488,8 +3511,9 @@ are also bound buffer-locally if `bibtex-dialect' is already buffer-local in the current buffer (for example, as a file-local variable). LOCAL is t for interactive calls." (interactive (list (intern (completing-read "Dialect: " - (mapcar 'list bibtex-dialect-list) - nil t)) t)) + (mapcar #'list bibtex-dialect-list) + nil t)) + t)) (let ((setfun (if (or local (local-variable-p 'bibtex-dialect)) (lambda (var val) (set (make-local-variable var) val)) 'set))) @@ -3506,7 +3530,7 @@ LOCAL is t for interactive calls." bibtex-dialect)))) (funcall setfun 'bibtex-entry-type (concat "@[ \t]*\\(?:" - (regexp-opt (mapcar 'car bibtex-entry-alist)) "\\)")) + (regexp-opt (mapcar #'car bibtex-entry-alist)) "\\)")) (funcall setfun 'bibtex-entry-head (concat "^[ \t]*\\(" bibtex-entry-type "\\)[ \t]*[({][ \t\n]*\\(" bibtex-reference-key "\\)")) @@ -3516,7 +3540,7 @@ LOCAL is t for interactive calls." (concat "^[ \t]*@[ \t]*\\(?:" (regexp-opt (append '("String" "Preamble") - (mapcar 'car bibtex-entry-alist))) "\\)")) + (mapcar #'car bibtex-entry-alist))) "\\)")) (setq imenu-generic-expression (list (list nil bibtex-entry-head bibtex-key-in-head)) imenu-case-fold-search t))) @@ -3549,11 +3573,13 @@ LOCAL is t for interactive calls." (let* ((entry (car elt)) (fname (intern (format "bibtex-%s" entry)))) (unless (fboundp fname) - (eval (list 'defun fname nil - (format "Insert a template for a @%s entry; see also `bibtex-entry'." - entry) - '(interactive "*") - `(bibtex-entry ,entry)))) + (defalias fname + (lambda () + (:documentation + (format "Insert a template for a @%s entry; see also `bibtex-entry'." + entry)) + (interactive "*") + (bibtex-entry entry)))) ;; Menu entries (define-key menu-map (vector fname) `(menu-item ,(or (nth 1 elt) (car elt)) ,fname)))) @@ -3608,8 +3634,8 @@ is non-nil." (insert "@" entry-type (bibtex-entry-left-delimiter)) (if key (insert key)) (save-excursion - (mapc 'bibtex-make-field (car field-list)) - (mapc 'bibtex-make-optional-field (cdr field-list)) + (mapc #'bibtex-make-field (car field-list)) + (mapc #'bibtex-make-optional-field (cdr field-list)) (if bibtex-comma-after-last-field (insert ",")) (insert "\n") @@ -3657,8 +3683,8 @@ When called interactively with a prefix arg, query for a value of ENTRY-TYPE." (insert (bibtex-field-left-delimiter))) (goto-char end))) (skip-chars-backward " \t\n") - (mapc 'bibtex-make-field required) - (mapc 'bibtex-make-optional-field optional))))) + (mapc #'bibtex-make-field required) + (mapc #'bibtex-make-optional-field optional))))) (defun bibtex-parse-entry (&optional content keep-opt-alt) "Parse entry at point, return an alist. @@ -4980,7 +5006,8 @@ If mark is active reformat entries in region, if not in whole buffer." ("Remove empty optional and alternative fields? " . opts-or-alts) ("Remove delimiters around pure numerical fields? " . numerical-fields) (,(concat (if bibtex-comma-after-last-field "Insert" "Remove") - " comma at end of entry? ") . last-comma) + " comma at end of entry? ") + . last-comma) ("Replace double page dashes by single ones? " . page-dashes) ("Delete whitespace at the beginning and end of fields? " . whitespace) ("Inherit booktitle? " . inherit-booktitle) @@ -5047,7 +5074,7 @@ entries from minibuffer." (goto-char (point-max)) (message "Buffer is now parsable. Please save it."))) -(define-obsolete-function-alias 'bibtex-complete 'completion-at-point "24.1") +(define-obsolete-function-alias 'bibtex-complete #'completion-at-point "24.1") (defun bibtex-completion-at-point-function () (let ((pnt (point)) (case-fold-search t) @@ -5258,8 +5285,8 @@ Return the URL or nil if none can be generated." ;; If SCHEME is set up correctly, ;; we should never reach this point (error "Match failed: %s" text))) - (if fmt (apply 'format fmt (nreverse obj)) - (apply 'concat (nreverse obj))))) + (if fmt (apply #'format fmt (nreverse obj)) + (apply #'concat (nreverse obj))))) (if (called-interactively-p 'interactive) (message "%s" url)) (unless no-browse (browse-url url))) (if (and (not url) (called-interactively-p 'interactive)) @@ -5289,10 +5316,11 @@ where FILE is the BibTeX file of ENTRY." (list (completing-read "Field: " (delete-dups - (apply 'append + (apply #'append bibtex-user-optional-fields - (mapcar (lambda (x) (mapcar 'car (apply 'append (nthcdr 2 x)))) - bibtex-entry-alist))) nil t) + (mapcar (lambda (x) (mapcar #'car (apply #'append (nthcdr 2 x)))) + bibtex-entry-alist))) + nil t) (read-string "Regexp: ") (if bibtex-search-entry-globally (not current-prefix-arg) diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index 86db6980433..722fc0a3137 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el @@ -44,28 +44,23 @@ "Align assignments to this column by default with \\[conf-align-assignments]. If this number is negative, the `=' comes before the whitespace. Use 0 to not align (only setting space according to `conf-assignment-space')." - :type 'integer - :group 'conf) + :type 'integer) (defcustom conf-javaprop-assignment-column 32 "Value for `conf-assignment-column' in Java properties buffers." - :type 'integer - :group 'conf) + :type 'integer) (defcustom conf-colon-assignment-column (- (abs conf-assignment-column)) "Value for `conf-assignment-column' in Java properties buffers." - :type 'integer - :group 'conf) + :type 'integer) (defcustom conf-assignment-space t "Put at least one space around assignments when aligning." - :type 'boolean - :group 'conf) + :type 'boolean) (defcustom conf-colon-assignment-space nil "Value for `conf-assignment-space' in colon style Conf mode buffers." - :type 'boolean - :group 'conf) + :type 'boolean) (defvar conf-mode-map (let ((map (make-sparse-keymap)) @@ -349,9 +344,37 @@ unbalanced, but hey...)" (scan-error depth)))) +(defun conf--guess-mode () + "Try to guess sub-mode of `conf-mode' based on buffer content." + (let ((unix 0) (win 0) (equal 0) (colon 0) (space 0) (jp 0)) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (skip-chars-forward " \t\f") + (cond ((eq (char-after) ?\#) (setq unix (1+ unix))) + ((eq (char-after) ?\;) (setq win (1+ win))) + ((eq (char-after) ?\[)) ; nop + ((eolp)) ; nop + ((eq (char-after) ?})) ; nop + ;; recognize at most double spaces within names + ((looking-at "[^ \t\n=:]+\\(?: ?[^ \t\n=:]+\\)*[ \t]*[=:]") + (if (eq (char-before (match-end 0)) ?=) + (setq equal (1+ equal)) + (setq colon (1+ colon)))) + ((looking-at "/[/*]") (setq jp (1+ jp))) + ((looking-at ".*{")) ; nop + ((setq space (1+ space)))) + (forward-line))) + (cond + ((> jp (max unix win 3)) #'conf-javaprop-mode) + ((> colon (max equal space)) #'conf-colon-mode) + ((> space (max equal colon)) #'conf-space-mode) + ((or (> win unix) (and (= win unix) (eq system-type 'windows-nt))) + #'conf-windows-mode) + (t #'conf-unix-mode)))) ;;;###autoload -(defun conf-mode () +(define-derived-mode conf-mode nil "Conf[?]" "Mode for Unix and Windows Conf files and Java properties. Most conf files know only three kinds of constructs: parameter assignments optionally grouped into sections and comments. Yet @@ -382,75 +405,41 @@ See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode', \\{conf-mode-map}" - (interactive) - ;; `conf-mode' plays two roles: it's the parent of several sub-modes - ;; but it's also the function that chooses between those submodes. - ;; To tell the difference between those two cases where the function - ;; might be called, we check `delay-mode-hooks'. - ;; (adopted from tex-mode.el) - (if (not delay-mode-hooks) - ;; try to guess sub-mode of conf-mode based on buffer content - (let ((unix 0) (win 0) (equal 0) (colon 0) (space 0) (jp 0)) - (save-excursion - (goto-char (point-min)) - (while (not (eobp)) - (skip-chars-forward " \t\f") - (cond ((eq (char-after) ?\#) (setq unix (1+ unix))) - ((eq (char-after) ?\;) (setq win (1+ win))) - ((eq (char-after) ?\[)) ; nop - ((eolp)) ; nop - ((eq (char-after) ?})) ; nop - ;; recognize at most double spaces within names - ((looking-at "[^ \t\n=:]+\\(?: ?[^ \t\n=:]+\\)*[ \t]*[=:]") - (if (eq (char-before (match-end 0)) ?=) - (setq equal (1+ equal)) - (setq colon (1+ colon)))) - ((looking-at "/[/*]") (setq jp (1+ jp))) - ((looking-at ".*{")) ; nop - ((setq space (1+ space)))) - (forward-line))) - (cond - ((> jp (max unix win 3)) (conf-javaprop-mode)) - ((> colon (max equal space)) (conf-colon-mode)) - ((> space (max equal colon)) (conf-space-mode)) - ((or (> win unix) (and (= win unix) (eq system-type 'windows-nt))) - (conf-windows-mode)) - (t (conf-unix-mode)))) - - (kill-all-local-variables) - (use-local-map conf-mode-map) - (setq major-mode 'conf-mode - mode-name "Conf[?]") - (set (make-local-variable 'font-lock-defaults) - '(conf-font-lock-keywords nil t nil nil)) - ;; Let newcomment.el decide this for itself. - ;; (set (make-local-variable 'comment-use-syntax) t) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'outline-regexp) - "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") - (set (make-local-variable 'outline-heading-end-regexp) - "[\n}]") - (set (make-local-variable 'outline-level) - 'conf-outline-level) - (set-syntax-table conf-mode-syntax-table) - (setq imenu-generic-expression - '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) - ;; [section] - (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) - ;; section { ... } - (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1))) - (run-mode-hooks 'conf-mode-hook))) + (setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil)) + ;; Let newcomment.el decide this for itself. + ;; (setq-local comment-use-syntax t) + (setq-local parse-sexp-ignore-comments t) + (setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") + (setq-local outline-heading-end-regexp "[\n}]") + (setq-local outline-level #'conf-outline-level) + (setq-local imenu-generic-expression + '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) + ;; [section] + (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) + ;; section { ... } + (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1)))) + +;; `conf-mode' plays two roles: it's the parent of several sub-modes +;; but it's also the function that chooses between those submodes. +;; To tell the difference between those two cases where the function +;; might be called, we check `delay-mode-hooks'. +;; (inspired from tex-mode.el) +(advice-add 'conf-mode :around + (lambda (orig-fun) + "Redirect to one of the submodes when called directly." + (funcall (if delay-mode-hooks orig-fun (conf--guess-mode))))) + + (defun conf-mode-initialize (comment &optional font-lock) "Initializations for sub-modes of `conf-mode'. COMMENT initializes `comment-start' and `comment-start-skip'. The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS." - (set (make-local-variable 'comment-start) comment) - (set (make-local-variable 'comment-start-skip) - (concat (regexp-quote comment-start) "+\\s *")) + (setq-local comment-start comment) + (setq-local comment-start-skip + (concat (regexp-quote comment-start) "+\\s *")) (if font-lock - (set (make-local-variable 'font-lock-defaults) - `(,font-lock nil t nil nil)))) + (setq-local font-lock-defaults `(,font-lock nil t nil nil)))) ;;;###autoload (define-derived-mode conf-unix-mode conf-mode "Conf[Unix]" @@ -497,13 +486,11 @@ x.1 = x.2.y.1.z.1 = x.2.y.1.z.2.zz =" (conf-mode-initialize "#" 'conf-javaprop-font-lock-keywords) - (set (make-local-variable 'conf-assignment-column) - conf-javaprop-assignment-column) - (set (make-local-variable 'conf-assignment-regexp) - ".+?\\([ \t]*[=: \t][ \t]*\\|$\\)") - (setq comment-start-skip "\\(?:#+\\|/[/*]+\\)\\s *") - (setq imenu-generic-expression - '(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1)))) + (setq-local conf-assignment-column conf-javaprop-assignment-column) + (setq-local conf-assignment-regexp ".+?\\([ \t]*[=: \t][ \t]*\\|$\\)") + (setq-local comment-start-skip "\\(?:#+\\|/[/*]+\\)\\s *") + (setq-local imenu-generic-expression + '(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1)))) ;;;###autoload (define-derived-mode conf-space-mode conf-unix-mode "Conf[Space]" @@ -529,20 +516,18 @@ class desktop add /dev/audio desktop add /dev/mixer desktop" (conf-mode-initialize "#" 'conf-space-font-lock-keywords) - (make-local-variable 'conf-assignment-sign) - (setq conf-assignment-sign nil) - (make-local-variable 'conf-space-keywords) + (setq-local conf-assignment-sign nil) (cond (buffer-file-name ;; We set conf-space-keywords directly, but a value which is ;; in the local variables list or interactively specified ;; (see the function conf-space-keywords) takes precedence. - (setq conf-space-keywords - (assoc-default buffer-file-name conf-space-keywords-alist - 'string-match)))) + (setq-local conf-space-keywords + (assoc-default buffer-file-name conf-space-keywords-alist + #'string-match)))) (conf-space-mode-internal) ;; In case the local variables list specifies conf-space-keywords, ;; recompute other things from that afterward. - (add-hook 'hack-local-variables-hook 'conf-space-mode-internal nil t)) + (add-hook 'hack-local-variables-hook #'conf-space-mode-internal nil t)) ;;;###autoload (defun conf-space-keywords (keywords) @@ -553,16 +538,16 @@ See `conf-space-mode'." (conf-space-mode)) (if (string-equal keywords "") (setq keywords nil)) - (setq conf-space-keywords keywords) + (setq-local conf-space-keywords keywords) (conf-space-mode-internal) (run-mode-hooks)) (defun conf-space-mode-internal () - (make-local-variable 'conf-assignment-regexp) - (setq conf-assignment-regexp - (if conf-space-keywords - (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)") - ".+?\\([ \t]+\\|$\\)")) + (setq-local conf-assignment-regexp + (if conf-space-keywords + (concat "\\(?:" conf-space-keywords + "\\)[ \t]+.+?\\([ \t]+\\|$\\)") + ".+?\\([ \t]+\\|$\\)")) ;; If Font Lock is already enabled, reenable it with new ;; conf-assignment-regexp. (when (and font-lock-mode @@ -596,17 +581,13 @@ For details see `conf-mode'. Example: <Multi_key> <exclam> <exclam> : \"\\241\" exclamdown <Multi_key> <c> <slash> : \"\\242\" cent" (conf-mode-initialize "#" 'conf-colon-font-lock-keywords) - (set (make-local-variable 'conf-assignment-space) - conf-colon-assignment-space) - (set (make-local-variable 'conf-assignment-column) - conf-colon-assignment-column) - (set (make-local-variable 'conf-assignment-sign) - ?:) - (set (make-local-variable 'conf-assignment-regexp) - ".+?\\([ \t]*:[ \t]*\\)") - (setq imenu-generic-expression - `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1) - ,@(cdr imenu-generic-expression)))) + (setq-local conf-assignment-space conf-colon-assignment-space) + (setq-local conf-assignment-column conf-colon-assignment-column) + (setq-local conf-assignment-sign ?:) + (setq-local conf-assignment-regexp ".+?\\([ \t]*:[ \t]*\\)") + (setq-local imenu-generic-expression + `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1) + ,@(cdr imenu-generic-expression)))) ;;;###autoload (define-derived-mode conf-ppd-mode conf-colon-mode "Conf[PPD]" diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 0d4a910a1db..747657b1ed5 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -67,7 +67,7 @@ (defconst scss-at-ids '("at-root" "content" "debug" "each" "else" "else if" "error" "extend" - "for" "function" "if" "import" "include" "mixin" "return" "warn" + "for" "function" "if" "import" "include" "mixin" "return" "use" "warn" "while") "Additional identifiers that appear in the form @foo in SCSS.") @@ -100,7 +100,7 @@ "Identifiers for types of media.") (defconst css-property-alist - ;; CSS 2.1 properties (http://www.w3.org/TR/CSS21/propidx.html). + ;; CSS 2.1 properties (https://www.w3.org/TR/CSS21/propidx.html). ;; ;; Properties duplicated by any of the CSS3 modules below have been ;; removed. @@ -119,7 +119,6 @@ ("cue" cue-before cue-after) ("cue-after" uri "none") ("cue-before" uri "none") - ("direction" "ltr" "rtl") ("display" "inline" "block" "list-item" "inline-block" "table" "inline-table" "table-row-group" "table-header-group" "table-footer-group" "table-row" "table-column-group" @@ -180,7 +179,6 @@ ("stress" number) ("table-layout" "auto" "fixed") ("top" length percentage "auto") - ("unicode-bidi" "normal" "embed" "bidi-override") ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle" "bottom" "text-bottom" percentage length) ("visibility" "visible" "hidden" "collapse") @@ -192,7 +190,7 @@ ("z-index" "auto" integer) ;; CSS Animations - ;; (http://www.w3.org/TR/css3-animations/#property-index) + ;; (https://www.w3.org/TR/css3-animations/#property-index) ("animation" single-animation-name time single-timing-function single-animation-iteration-count single-animation-direction single-animation-fill-mode single-animation-play-state) @@ -206,7 +204,7 @@ ("animation-timing-function" single-timing-function) ;; CSS Backgrounds and Borders Module Level 3 - ;; (http://www.w3.org/TR/css3-background/#property-index) + ;; (https://www.w3.org/TR/css3-background/#property-index) ("background" bg-layer final-bg-layer) ("background-attachment" attachment) ("background-clip" box) @@ -251,7 +249,7 @@ ("box-shadow" "none" shadow) ;; CSS Basic User Interface Module Level 3 (CSS3 UI) - ;; (http://www.w3.org/TR/css3-ui/#property-index) + ;; (https://www.w3.org/TR/css3-ui/#property-index) ("box-sizing" "content-box" "border-box") ("caret-color" "auto" color) ("cursor" uri x y "auto" "default" "none" "context-menu" "help" @@ -274,10 +272,14 @@ ("text-overflow" "clip" "ellipsis" string) ;; CSS Color Module Level 3 - ;; (http://www.w3.org/TR/css3-color/#property) + ;; (https://www.w3.org/TR/css3-color/#property) ("color" color) ("opacity" alphavalue) + ;; CSS Containment Module Level 1 + ;; (https://www.w3.org/TR/css-contain-1/#property-index) + ("contain" "none" "strict" "content" "size" "layout" "paint") + ;; CSS Grid Layout Module Level 1 ;; (https://www.w3.org/TR/css-grid-1/#property-index) ("grid" grid-template grid-template-rows "auto-flow" "dense" @@ -302,7 +304,7 @@ ("grid-template-rows" "none" track-list auto-track-list) ;; CSS Flexible Box Layout Module Level 1 - ;; (http://www.w3.org/TR/css-flexbox-1/#property-index) + ;; (https://www.w3.org/TR/css-flexbox-1/#property-index) ("align-content" "flex-start" "flex-end" "center" "space-between" "space-around" "stretch") ("align-items" "flex-start" "flex-end" "center" "baseline" @@ -321,7 +323,7 @@ ("order" integer) ;; CSS Fonts Module Level 3 - ;; (http://www.w3.org/TR/css3-fonts/#property-index) + ;; (https://www.w3.org/TR/css3-fonts/#property-index) ("font" font-style font-variant-css21 font-weight font-stretch font-size line-height font-family "caption" "icon" "menu" "message-box" "small-caption" "status-bar") @@ -417,7 +419,7 @@ ("columns" column-width column-count) ;; CSS Overflow Module Level 3 - ;; (http://www.w3.org/TR/css-overflow-3/#property-index) + ;; (https://www.w3.org/TR/css-overflow-3/#property-index) ("max-lines" "none" integer) ("overflow" "visible" "hidden" "scroll" "auto" "paged-x" "paged-y" "paged-x-controls" "paged-y-controls" "fragments") @@ -446,7 +448,7 @@ ("text-underline-position" "auto" "under" "left" "right") ;; CSS Text Module Level 3 - ;; (http://www.w3.org/TR/css3-text/#property-index) + ;; (https://www.w3.org/TR/css3-text/#property-index) ("hanging-punctuation" "none" "first" "force-end" "allow-end" "last") ("hyphens" "none" "manual" "auto") @@ -468,7 +470,7 @@ ("word-wrap" "normal" "break-word") ;; CSS Transforms Module Level 1 - ;; (http://www.w3.org/TR/css3-2d-transforms/#property-index) + ;; (https://www.w3.org/TR/css3-2d-transforms/#property-index) ("backface-visibility" "visible" "hidden") ("perspective" "none" length) ("perspective-origin" "left" "center" "right" "top" "bottom" @@ -479,7 +481,7 @@ ("transform-style" "flat" "preserve-3d") ;; CSS Transitions - ;; (http://www.w3.org/TR/css3-transitions/#property-index) + ;; (https://www.w3.org/TR/css3-transitions/#property-index) ("transition" single-transition) ("transition-delay" time) ("transition-duration" time) @@ -490,8 +492,18 @@ ;; (https://www.w3.org/TR/css-will-change-1/#property-index) ("will-change" "auto" animateable-feature) + ;; CSS Writing Modes Level 3 + ;; (https://www.w3.org/TR/css-writing-modes-3/#property-index) + ;; "glyph-orientation-vertical" is obsolete and left out. + ("direction" "ltr" "rtl") + ("text-combine-upright" "none" "all") + ("text-orientation" "mixed" "upright" "sideways") + ("unicode-bidi" "normal" "embed" "isolate" "bidi-override" + "isolate-override" "plaintext") + ("writing-mode" "horizontal-tb" "vertical-rl" "vertical-lr") + ;; Filter Effects Module Level 1 - ;; (http://www.w3.org/TR/filter-effects/#property-index) + ;; (https://www.w3.org/TR/filter-effects/#property-index) ("color-interpolation-filters" "auto" "sRGB" "linearRGB") ("filter" "none" filter-function-list) ("flood-color" color) @@ -874,7 +886,7 @@ cannot be completed sensibly: `custom-ident', (defconst css-escapes-re "\\\\\\(?:[^\000-\037\177]\\|[[:xdigit:]]+[ \n\t\r\f]?\\)") -(defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)")) +(defconst css-nmchar-re (concat "\\(?:[-_[:alnum:]]\\|" css-escapes-re "\\)")) (defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)")) (defconst css-ident-re ;; (concat css-nmstart-re css-nmchar-re "*") ;; Apparently, "at rules" names can start with a dash, e.g. @-moz-keyframes. @@ -1137,17 +1149,6 @@ returns, point will be at the end of the recognized color." ;; Evaluate to the color if the name is found. ((css--named-color start-point match)))) -(defun css--contrasty-color (name) - "Return a color that contrasts with NAME. -NAME is of any form accepted by `color-distance'. -The returned color will be usable by Emacs and will contrast -with NAME; in particular so that if NAME is used as a background -color, the returned color can be used as the foreground and still -be readable." - ;; See bug#25525 for a discussion of this. - (if (> (color-distance name "black") 292485) - "black" "white")) - (defcustom css-fontify-colors t "Whether CSS colors should be fontified using the color as the background. When non-`nil', a text representing CSS color will be fontified @@ -1187,7 +1188,8 @@ START and END are buffer positions." (add-text-properties start (point) (list 'face (list :background color - :foreground (css--contrasty-color color) + :foreground (readable-foreground-color + color) :box '(:line-width -1)))))))))))) extended-region)) @@ -1354,21 +1356,19 @@ the string PROPERTY." (defun css--complete-property-value () "Complete property value at point." - (let ((property - (save-excursion - (re-search-backward ":[^/]" (line-beginning-position) t) - (when (eq (char-after) ?:) - (let ((property-end (point))) - (skip-chars-backward "-[:alnum:]") - (let ((prop (buffer-substring (point) property-end))) - (car (member prop css-property-ids)))))))) + (let ((property (and (looking-back "\\([[:alnum:]-]+\\):[^/][^;]*" + (or (ppss-innermost-start (syntax-ppss)) + (point)) + t) + (member (match-string-no-properties 1) + css-property-ids)))) (when property (let ((end (point))) (save-excursion (skip-chars-backward "[:graph:]") (list (point) end (append '("inherit" "initial" "unset") - (css--property-values property)))))))) + (css--property-values (car property))))))))) (defvar css--html-tags (mapcar #'car html-tag-alist) "List of HTML tags. @@ -1881,12 +1881,9 @@ on what is seen near point." (list (let* ((sym (css--mdn-find-symbol)) (enable-recursive-minibuffers t) - (value (completing-read - (if sym - (format "Describe CSS symbol (default %s): " sym) - "Describe CSS symbol: ") - css--mdn-completion-list nil nil nil - 'css--mdn-lookup-history sym))) + (value (completing-read (format-prompt "Describe CSS symbol" sym) + css--mdn-completion-list nil nil nil + 'css--mdn-lookup-history sym))) (if (equal value "") sym value)))) (when symbol ;; If we see a single-colon pseudo-element like ":after", turn it diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 4c24e70d1f7..2757074f9f8 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -57,7 +57,6 @@ (defcustom flyspell-highlight-flag t "How Flyspell should indicate misspelled words. Non-nil means use highlight, nil means use minibuffer messages." - :group 'flyspell :type 'boolean) (defcustom flyspell-mark-duplications-flag t @@ -65,12 +64,10 @@ Non-nil means use highlight, nil means use minibuffer messages." See `flyspell-mark-duplications-exceptions' to add exceptions to this rule. Detection of repeated words is not implemented in \"large\" regions; see variable `flyspell-large-region'." - :group 'flyspell :type 'boolean) (defcustom flyspell-case-fold-duplications t "Non-nil means Flyspell matches duplicate words case-insensitively." - :group 'flyspell :type 'boolean :version "27.1") @@ -87,9 +84,8 @@ dictionary name (`ispell-local-dictionary' or EXCEPTION-LIST is a list of strings. The checked word is downcased before comparing with these exceptions." - :group 'flyspell :type '(alist :key-type (choice (const :tag "All dictionaries" nil) - string) + regexp) :value-type (repeat string)) :version "24.1") @@ -97,7 +93,6 @@ downcased before comparing with these exceptions." "If non-nil, sort the corrections before popping them. The sorting is controlled by the `flyspell-sort-corrections-function' variable, and defaults to sorting alphabetically." - :group 'flyspell :version "21.1" :type 'boolean) @@ -109,8 +104,7 @@ function takes three parameters -- the two correction candidates to be sorted, and the third parameter is the word that's being corrected." :version "26.1" - :type 'function - :group 'flyspell) + :type 'function) (defun flyspell-sort-corrections-alphabetically (corr1 corr2 _) (string< corr1 corr2)) @@ -130,14 +124,12 @@ Flyspell uses a different face (`flyspell-duplicate') to highlight it. This variable specifies how far to search to find such a duplicate. -1 means no limit (search the whole buffer). 0 means do not search for duplicate unrecognized spellings." - :group 'flyspell :version "24.5" ; -1 -> 400000 :type '(choice (const :tag "no limit" -1) number)) (defcustom flyspell-delay 3 "The number of seconds to wait before checking, after a \"delayed\" command." - :group 'flyspell :type 'number) (defcustom flyspell-persistent-highlight t @@ -147,12 +139,10 @@ is highlighted, and the highlight is turned off as soon as point moves off the misspelled word. Make sure this variable is non-nil if you use `flyspell-region'." - :group 'flyspell :type 'boolean) (defcustom flyspell-highlight-properties t "Non-nil means highlight incorrect words even if a property exists for this word." - :group 'flyspell :type 'boolean) (defcustom flyspell-default-delayed-commands @@ -164,7 +154,6 @@ Make sure this variable is non-nil if you use `flyspell-region'." backward-delete-char-untabify) "The standard list of delayed commands for Flyspell. See `flyspell-delayed-commands'." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) @@ -172,7 +161,6 @@ See `flyspell-delayed-commands'." "List of commands that are \"delayed\" for Flyspell mode. After these commands, Flyspell checking is delayed for a short time, whose length is specified by `flyspell-delay'." - :group 'flyspell :type '(repeat (symbol))) (defcustom flyspell-default-deplacement-commands @@ -182,7 +170,6 @@ whose length is specified by `flyspell-delay'." scroll-down) "The standard list of deplacement commands for Flyspell. See variable `flyspell-deplacement-commands'." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) @@ -190,18 +177,15 @@ See variable `flyspell-deplacement-commands'." "List of commands that are \"deplacement\" for Flyspell mode. After these commands, Flyspell checking is performed only if the previous command was not the very same command." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) (defcustom flyspell-issue-welcome-flag t "Non-nil means that Flyspell should display a welcome message when started." - :group 'flyspell :type 'boolean) (defcustom flyspell-issue-message-flag t "Non-nil means that Flyspell emits messages when checking words." - :group 'flyspell :type 'boolean) (defcustom flyspell-incorrect-hook nil @@ -213,7 +197,6 @@ of possible corrections as returned by `ispell-parse-output'. If any of the functions return non-nil, the word is not highlighted as incorrect." - :group 'flyspell :version "21.1" :type 'hook) @@ -225,50 +208,43 @@ when flyspell is started, the value of that variable is used instead of `flyspell-default-dictionary' to select the default dictionary. Otherwise, if `flyspell-default-dictionary' is nil, it means to use Ispell's ultimate default dictionary." - :group 'flyspell :version "21.1" :type '(choice string (const :tag "Default" nil))) (defcustom flyspell-tex-command-regexp "\\(\\(begin\\|end\\)[ \t]*{\\|\\(cite[a-z*]*\\|label\\|ref\\|eqref\\|usepackage\\|documentclass\\)[ \t]*\\(\\[[^]]*\\]\\)?{[^{}]*\\)" "A string that is the regular expression that matches TeX commands." - :group 'flyspell :version "21.1" - :type 'string) + :type 'regexp) (defcustom flyspell-check-tex-math-command nil "Non-nil means check even inside TeX math environment. TeX math environments are discovered by `texmathp', implemented inside AUCTeX package. That package may be found at URL `https://www.gnu.org/software/auctex/'" - :group 'flyspell :type 'boolean) (defcustom flyspell-dictionaries-that-consider-dash-as-word-delimiter '("francais" "deutsch8" "norsk") "List of dictionary names that consider `-' as word delimiter." - :group 'flyspell :version "21.1" :type '(repeat (string))) (defcustom flyspell-abbrev-p nil "If non-nil, add correction to abbreviation table." - :group 'flyspell :version "21.1" :type 'boolean) (defcustom flyspell-use-global-abbrev-table-p nil "If non-nil, prefer global abbrev table to local abbrev table." - :group 'flyspell :version "21.1" :type 'boolean) (defcustom flyspell-mode-line-string " Fly" "String displayed on the mode line when flyspell is active. Set this to nil if you don't want a mode line indicator." - :group 'flyspell :type '(choice string (const :tag "None" nil))) (defcustom flyspell-large-region 1000 @@ -282,30 +258,25 @@ Doubled words are not detected in a large region, because Ispell does not check for them. If this variable is nil, all regions are treated as small." - :group 'flyspell :version "21.1" :type '(choice number (const :tag "All small" nil))) (defcustom flyspell-insert-function (function insert) "Function for inserting word by flyspell upon correction." - :group 'flyspell :type 'function) (defcustom flyspell-before-incorrect-word-string nil "String used to indicate an incorrect word starting." - :group 'flyspell :type '(choice string (const nil))) (defcustom flyspell-after-incorrect-word-string nil "String used to indicate an incorrect word ending." - :group 'flyspell :type '(choice string (const nil))) (defvar flyspell-mode-map) (defcustom flyspell-use-meta-tab t "Non-nil means that flyspell uses M-TAB to correct word." - :group 'flyspell :type 'boolean :initialize 'custom-initialize-default :set (lambda (sym val) @@ -316,8 +287,7 @@ If this variable is nil, all regions are treated as small." (defcustom flyspell-auto-correct-binding [(control ?\;)] "The key binding for flyspell auto correction." - :type 'key-sequence - :group 'flyspell) + :type 'key-sequence) ;;*---------------------------------------------------------------------*/ ;;* Mode specific options */ @@ -417,9 +387,13 @@ like <img alt=\"Some thing.\">." ;;*---------------------------------------------------------------------*/ ;;* Programming mode */ ;;*---------------------------------------------------------------------*/ -(defvar flyspell-prog-text-faces +(defcustom flyspell-prog-text-faces '(font-lock-string-face font-lock-comment-face font-lock-doc-face) - "Faces corresponding to text in programming-mode buffers.") + "Faces corresponding to text in programming-mode buffers." + :type '(set (const font-lock-string-face) + (const font-lock-comment-face) + (const font-lock-doc-face)) + :version "28.1") (defun flyspell-generic-progmode-verify () "Used for `flyspell-generic-check-word-predicate' in programming modes." @@ -428,8 +402,8 @@ like <img alt=\"Some thing.\">." (let ((f (get-text-property (1- (point)) 'face))) (memq f flyspell-prog-text-faces)))) -;; Records the binding of M-TAB in effect before flyspell was activated. -(defvar flyspell--prev-meta-tab-binding) +(defvar flyspell--prev-meta-tab-binding nil + "Records the binding of M-TAB in effect before flyspell was activated.") ;;;###autoload (defun flyspell-prog-mode () @@ -475,6 +449,22 @@ like <img alt=\"Some thing.\">." map) "Minor mode keymap for Flyspell mode--for the whole buffer.") +;; correct on mouse 3 +(defun flyspell--set-use-mouse-3-for-menu (var value) + (set-default var value) + (if value + (progn (define-key flyspell-mouse-map [mouse-2] nil) + (define-key flyspell-mouse-map [down-mouse-3] 'flyspell-correct-word)) + (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word) + (define-key flyspell-mouse-map [down-mouse-3] nil))) + +(defcustom flyspell-use-mouse-3-for-menu nil + "Non-nil means to bind `mouse-3' to `flyspell-correct-word'. +If this is set, also unbind `mouse-2'." + :type 'boolean + :set 'flyspell--set-use-mouse-3-for-menu + :version "28.1") + ;; dash character machinery (defvar flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") @@ -493,8 +483,7 @@ like <img alt=\"Some thing.\">." (t :underline t :inherit error)) "Flyspell face for misspelled words." - :version "24.4" - :group 'flyspell) + :version "24.4") (defface flyspell-duplicate '((((supports :underline (:style wave))) @@ -503,8 +492,7 @@ like <img alt=\"Some thing.\">." :underline t :inherit warning)) "Flyspell face for words that appear twice in a row. See also `flyspell-duplicate-distance'." - :version "24.4" - :group 'flyspell) + :version "24.4") (defvar flyspell-overlay nil) @@ -536,17 +524,33 @@ invoking `ispell-change-dictionary'. Consider using the `ispell-parser' to check your text. For instance consider adding: -\(add-hook \\='tex-mode-hook (function (lambda () (setq ispell-parser \\='tex)))) +\(add-hook \\='tex-mode-hook (lambda () (setq ispell-parser \\='tex))) in your init file. \\[flyspell-region] checks all words inside a region. \\[flyspell-buffer] checks the whole buffer." - :lighter flyspell-mode-line-string + :lighter (flyspell-mode-line-string + ;; If `flyspell-mode-line-string' is nil, then nothing of + ;; the following is displayed in the mode line. + ((:propertize flyspell-mode-line-string) + (:propertize + (:eval + (concat "/" (substring (or ispell-local-dictionary + ispell-dictionary + "--") + 0 2))) + help-echo "mouse-1: Change dictionary" + local-map (keymap + (mode-line keymap + (mouse-1 . ispell-change-dictionary)))))) :keymap flyspell-mode-map :group 'flyspell (if flyspell-mode (condition-case err - (flyspell-mode-on) + (progn + (when flyspell-use-mouse-3-for-menu + (flyspell--set-use-mouse-3-for-menu 'flyspell-use-mouse-3-for-menu t)) + (flyspell-mode-on (called-interactively-p 'interactive))) (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) @@ -563,12 +567,9 @@ in your init file. (custom-add-option 'text-mode-hook 'turn-on-flyspell) -;;*---------------------------------------------------------------------*/ -;;* flyspell-buffers ... */ -;;* ------------------------------------------------------------- */ -;;* For remembering buffers running flyspell */ -;;*---------------------------------------------------------------------*/ -(defvar flyspell-buffers nil) +(defvar flyspell-buffers nil + "For remembering buffers running flyspell") +(make-obsolete-variable 'flyspell-buffers "not used." "28.1") ;;*---------------------------------------------------------------------*/ ;;* flyspell-minibuffer-p ... */ @@ -624,8 +625,12 @@ in your init file. ;;*---------------------------------------------------------------------*/ ;;* flyspell-mode-on ... */ ;;*---------------------------------------------------------------------*/ -(defun flyspell-mode-on () - "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." +(defun flyspell-mode-on (&optional show-msg) + "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead. + +If optional argument SHOW-MSG is non-nil, show a welcome message +if `flyspell-issue-message-flag' and `flyspell-issue-welcome-flag' +are both non-nil." (ispell-set-spellchecker-params) ; Initialize variables and dicts alists (setq ispell-highlight-face 'flyspell-incorrect) ;; local dictionaries setup @@ -657,15 +662,17 @@ in your init file. (setq flyspell-generic-check-word-predicate mode-predicate))) ;; the welcome message (if (and flyspell-issue-message-flag - flyspell-issue-welcome-flag - (called-interactively-p 'interactive)) - (let ((binding (where-is-internal 'flyspell-auto-correct-word - nil 'non-ascii))) - (message "%s" - (if binding - (format "Welcome to flyspell. Use %s or Mouse-2 to correct words." - (key-description binding)) - "Welcome to flyspell. Use Mouse-2 to correct words."))))) + flyspell-issue-welcome-flag + show-msg) + (let* ((binding (where-is-internal 'flyspell-auto-correct-word + nil 'non-ascii)) + (mouse-button (if flyspell-use-mouse-3-for-menu + "Mouse-3" "Mouse-2"))) + (message (format-message + "Welcome to Flyspell. Use %s to correct words." + (if binding + (format "`%s' or `%s'" (key-description binding) mouse-button) + (format "`%s'" mouse-button))))))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-delay-commands ... */ @@ -1815,7 +1822,9 @@ for the overlay." (overlay-put overlay 'mouse-face mouse-face) (overlay-put overlay 'flyspell-overlay t) (overlay-put overlay 'evaporate t) - (overlay-put overlay 'help-echo "mouse-2: correct word at point") + (overlay-put overlay 'help-echo (concat (if flyspell-use-mouse-3-for-menu + "mouse-3" + "mouse-2") ": correct word at point")) ;; If misspelled text has a 'keymap' property, let that remain in ;; effect for the bindings that flyspell-mouse-map doesn't override. (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap)) @@ -1912,7 +1921,7 @@ before point that's highlighted as misspelled." (while (and (setq pos (previous-overlay-change pos)) (not (= pos pos1))) (setq pos1 pos) - (if (> pos (point-min)) + (if (>= pos (point-min)) (progn (setq ovs (overlays-at pos)) (while (consp ovs) diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 65f61644b6d..14de77cd542 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -44,6 +44,7 @@ ;; ispell-buffer ;; ispell-message ;; ispell-comments-and-strings +;; ispell-comment-or-string-at-point ;; ispell-continue ;; ispell-complete-word ;; ispell-complete-word-interior-frag @@ -197,14 +198,13 @@ Must be greater than 1." :type 'integer :group 'ispell) -;; XXX Add enchant to this list once enchant >= 2.1.0 is widespread. -;; Before that, adding it is useless, as if it is found, it will just -;; cause an error; and one of the other spelling engines below is -;; almost certainly installed in any case, for enchant to use. (defcustom ispell-program-name (or (executable-find "aspell") (executable-find "ispell") (executable-find "hunspell") + ;; Enchant is commonly installed as `enchant-2', so use this + ;; name and avoid old versions of `enchant'. + (executable-find "enchant-2") "ispell") "Program invoked by \\[ispell-word] and \\[ispell-region] commands." :type 'string @@ -329,7 +329,7 @@ The function must take one string argument and return a string." :group 'ispell) ;; FIXME framepop.el last updated c 2003 (?), -;; probably something else replaces it these days. +;; use posframe. (defcustom ispell-use-framepop-p nil "When non-nil ispell uses framepop to display choices in a dedicated frame. You can set this variable to dynamically use framepop if you are in a @@ -621,15 +621,6 @@ For Aspell, non-nil also means to try to automatically find its dictionaries. Earlier Aspell versions do not consistently support charset encoding. Handling this would require some extra guessing in `ispell-aspell-find-dictionary'.") -(defvar ispell-aspell-supports-utf8 nil - "Non-nil if Aspell has consistent command line UTF-8 support. Obsolete. -ispell.el and flyspell.el will use for this purpose the more generic -variable `ispell-encoding8-command' for both Aspell and Hunspell. Is left -here just for backwards compatibility.") - -(make-obsolete-variable 'ispell-aspell-supports-utf8 - 'ispell-encoding8-command "23.1") - (defvar ispell-dicts-name2locale-equivs-alist '(("american" "en_US") ("brasileiro" "pt_BR") @@ -682,9 +673,7 @@ Otherwise returns the library directory name, if that is defined." ;; all versions, since versions earlier than 3.0.09 didn't identify ;; themselves on startup. (interactive "p") - (let ((default-directory (or (and (boundp 'temporary-file-directory) - temporary-file-directory) - default-directory)) + (let ((default-directory (or temporary-file-directory default-directory)) (get-config-var (lambda (var) (when (re-search-forward @@ -695,13 +684,9 @@ Otherwise returns the library directory name, if that is defined." (with-temp-buffer (setq status (ispell-call-process ispell-program-name nil t nil - ;; aspell doesn't accept the -vv switch. (let ((case-fold-search - (memq system-type '(ms-dos windows-nt))) - (speller - (file-name-nondirectory ispell-program-name))) - ;; Assume anything that isn't `aspell' is Ispell. - (if (string-match "\\`aspell" speller) "-v" "-vv")))) + (memq system-type '(ms-dos windows-nt)))) + "-vv"))) (goto-char (point-min)) (if interactivep ;; Report version information of ispell @@ -782,18 +767,23 @@ Otherwise returns the library directory name, if that is defined." (setq ispell-really-hunspell nil)))))) result)) +(defmacro ispell-with-safe-default-directory (&rest body) + "Execute the forms in BODY with a reasonable +`default-directory'." + (declare (indent 0) (debug t)) + `(let ((default-directory default-directory)) + (unless (file-accessible-directory-p default-directory) + (setq default-directory (expand-file-name "~/"))) + ,@body)) + (defun ispell-call-process (&rest args) - "Like `call-process' but defend against bad `default-directory'." - (let ((default-directory default-directory)) - (unless (file-accessible-directory-p default-directory) - (setq default-directory (expand-file-name "~/"))) + "Like `call-process', but defend against bad `default-directory'." + (ispell-with-safe-default-directory (apply 'call-process args))) (defun ispell-call-process-region (&rest args) - "Like `call-process-region' but defend against bad `default-directory'." - (let ((default-directory default-directory)) - (unless (file-accessible-directory-p default-directory) - (setq default-directory (expand-file-name "~/"))) + "Like `call-process-region', but defend against bad `default-directory'." + (ispell-with-safe-default-directory (apply 'call-process-region args))) (defvar ispell-debug-buffer) @@ -1106,28 +1096,38 @@ to dictionaries found, and will remove aliases from the list in `ispell-dicts-name2locale-equivs-alist' if an explicit dictionary from that list was found." (let ((hunspell-found-dicts - (split-string - (with-temp-buffer - (ispell-call-process ispell-program-name - null-device - t - nil - "-D" - ;; Use -a to prevent Hunspell from - ;; trying to initialize its - ;; curses/termcap UI, which causes it - ;; to crash or fail to start in some - ;; MS-Windows ports. - "-a" - ;; Hunspell 1.7.0 (and later?) won't - ;; show LOADED DICTIONARY unless - ;; there's at least one file argument - ;; on the command line. So we feed - ;; it with the null device. - null-device) - (buffer-string)) - "[\n\r]+" - t)) + (seq-filter + (lambda (str) + (when (string-match + ;; Hunspell gives this error when there is some + ;; installation problem, for example if $LANG is unset. + (concat "^Can't open affix or dictionary files " + "for dictionary named \"default\".$") + str) + (user-error "Hunspell error (is $LANG unset?): %s" str)) + (file-name-absolute-p str)) + (split-string + (with-temp-buffer + (ispell-call-process ispell-program-name + null-device + t + nil + "-D" + ;; Use -a to prevent Hunspell from + ;; trying to initialize its + ;; curses/termcap UI, which causes it + ;; to crash or fail to start in some + ;; MS-Windows ports. + "-a" + ;; Hunspell 1.7.0 (and later?) won't + ;; show LOADED DICTIONARY unless + ;; there's at least one file argument + ;; on the command line. So we feed + ;; it with the null device. + null-device) + (buffer-string)) + "[\n\r]+" + t))) hunspell-default-dict hunspell-default-dict-entry hunspell-multi-dict) @@ -1217,13 +1217,14 @@ Internal use.") (defun ispell--call-enchant-lsmod (&rest args) "Call enchant-lsmod with ARGS and return the output as string." (with-output-to-string - (with-current-buffer - standard-output + (with-current-buffer standard-output (apply #'ispell-call-process (replace-regexp-in-string "enchant\\(-[0-9]\\)?\\'" "enchant-lsmod\\1" ispell-program-name) - nil t nil args)))) + ;; We discard stderr here because enchant-lsmod can emit + ;; unrelated warnings that will confuse us. + nil '(t nil) nil args)))) (defun ispell--get-extra-word-characters (&optional lang) "Get the extra word characters for LANG as a character class. @@ -1237,11 +1238,11 @@ If LANG is omitted, get the extra word characters for the default language." "Find Enchant's dictionaries, and record in `ispell-enchant-dictionary-alist'." (let* ((dictionaries (split-string - (ispell--call-enchant-lsmod "-list-dicts" (buffer-string)) " ([^)]+)\n")) + (ispell--call-enchant-lsmod "-list-dicts") " ([^)]+)\n" t)) (found (mapcar #'(lambda (lang) `(,lang "[[:alpha:]]" "[^[:alpha:]]" - ,(ispell--get-extra-word-characters) t nil nil utf-8)) + ,(ispell--get-extra-word-characters lang) t nil nil utf-8)) dictionaries))) ;; Merge into FOUND any elements from the standard ispell-dictionary-base-alist ;; which have no element in FOUND at all. @@ -2463,14 +2464,14 @@ SPC: Accept word this time. (progn (require 'ehelp) (with-electric-help - (function (lambda () - ;;This shouldn't be necessary: with-electric-help needs - ;; an optional argument telling it about the smallest - ;; acceptable window-height of the help buffer. - ;;(if (< (window-height) 15) - ;; (enlarge-window - ;; (- 15 (ispell-adjusted-window-height)))) - (princ "Selections are: + (lambda () + ;;This shouldn't be necessary: with-electric-help needs + ;; an optional argument telling it about the smallest + ;; acceptable window-height of the help buffer. + ;;(if (< (window-height) 15) + ;; (enlarge-window + ;; (- 15 (ispell-adjusted-window-height)))) + (princ "Selections are: DIGIT: Replace the word with a digit offered in the *Choices* buffer. SPC: Accept word this time. @@ -2490,7 +2491,7 @@ SPC: Accept word this time. `C-l': Redraw screen. `C-r': Recursive edit. `C-z': Suspend Emacs or iconify frame.") - nil)))) + nil))) (let ((help-1 (concat "[r/R]eplace word; [a/A]ccept for this session; " @@ -3273,15 +3274,15 @@ otherwise, the current line is skipped." Generated from `ispell-tex-skip-alists'." (concat ;; raw tex keys - (mapconcat (function (lambda (lst) (car lst))) + (mapconcat (lambda (lst) (car lst)) (car ispell-tex-skip-alists) "\\|") "\\|" ;; keys wrapped in begin{} - (mapconcat (function (lambda (lst) - (concat "\\\\begin[ \t\n]*{[ \t\n]*" - (car lst) - "[ \t\n]*}"))) + (mapconcat (lambda (lst) + (concat "\\\\begin[ \t\n]*{[ \t\n]*" + (car lst) + "[ \t\n]*}")) (car (cdr ispell-tex-skip-alists)) "\\|"))) @@ -3591,24 +3592,40 @@ Returns the sum SHIFT due to changes in word replacements." ;;;###autoload -(defun ispell-comments-and-strings () - "Check comments and strings in the current buffer for spelling errors." - (interactive) - (goto-char (point-min)) +(defun ispell-comments-and-strings (&optional start end) + "Check comments and strings in the current buffer for spelling errors. +If called interactively with an active region, check only comments and +strings in the region. +When called from Lisp, START and END buffer positions can be provided +to limit the check." + (interactive (when (use-region-p) (list (region-beginning) (region-end)))) + (unless end (setq end (point-max))) + (goto-char (or start (point-min))) (let (state done) (while (not done) (setq done t) - (setq state (parse-partial-sexp (point) (point-max) - nil nil state 'syntax-table)) + (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) (if (or (nth 3 state) (nth 4 state)) (let ((start (point))) - (setq state (parse-partial-sexp start (point-max) + (setq state (parse-partial-sexp start end nil nil state 'syntax-table)) (if (or (nth 3 state) (nth 4 state)) (error "Unterminated string or comment")) (save-excursion (setq done (not (ispell-region start (point)))))))))) +;;;###autoload +(defun ispell-comment-or-string-at-point () + "Check the comment or string containing point for spelling errors." + (interactive) + (save-excursion + (let ((state (syntax-ppss))) + (if (or (nth 3 state) (nth 4 state)) + (ispell-region (nth 8 state) + (progn (parse-partial-sexp (point) (point-max) + nil nil state 'syntax-table) + (point))) + (user-error "Not inside a string or comment"))))) ;;;###autoload (defun ispell-buffer () @@ -3687,11 +3704,10 @@ Standard ispell choices are then available." ((string-equal (upcase word) word) (setq possibilities (mapcar #'upcase possibilities))) ((eq (upcase (aref word 0)) (aref word 0)) - (setq possibilities (mapcar (function - (lambda (pos) - (if (eq (aref word 0) (aref pos 0)) - pos - (capitalize pos)))) + (setq possibilities (mapcar (lambda (pos) + (if (eq (aref word 0) (aref pos 0)) + pos + (capitalize pos))) possibilities)))) (setq case-fold-search case-fold-search-val) (save-window-excursion @@ -3734,8 +3750,7 @@ looking for a dictionary, please see the distribution of the GNU ispell program, or do an Internet search; there are various dictionaries available on the net." (interactive) - (if (and (boundp 'transient-mark-mode) transient-mark-mode - (boundp 'mark-active) mark-active) + (if (and transient-mark-mode mark-active) (ispell-region (region-beginning) (region-end)) (ispell-buffer))) @@ -3923,7 +3938,7 @@ in your init file: You can bind this to the key C-c i in GNUS or mail by adding to `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression: - (function (lambda () (local-set-key \"\\C-ci\" \\='ispell-message)))" + (lambda () (local-set-key \"\\C-ci\" \\='ispell-message))" (interactive) (save-excursion (goto-char (point-min)) @@ -4200,7 +4215,7 @@ Both should not be used to define a buffer-local dictionary." (let (line-okay search done found) (while (not done) (let ((case-fold-search nil)) - (setq search (search-forward ispell-words-keyword nil 'move) + (setq search (search-forward ispell-words-keyword nil t) found (or found search) line-okay (< (+ (length word) 1 ; 1 for space after word.. (progn (end-of-line) (current-column))) @@ -4211,8 +4226,10 @@ Both should not be used to define a buffer-local dictionary." (setq done t) (if (null search) (progn - (open-line 1) - (unless found (newline)) + (if found (insert "\n") ;; after an existing LocalWords + (goto-char (point-max)) ;; no LocalWords, go to end of file + (open-line 1) + (newline)) (insert (if comment-start (concat (progn diff --git a/lisp/textmodes/mhtml-mode.el b/lisp/textmodes/mhtml-mode.el index b9161d9697e..329f3e7241d 100644 --- a/lisp/textmodes/mhtml-mode.el +++ b/lisp/textmodes/mhtml-mode.el @@ -22,6 +22,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) +(eval-when-compile (require 'pcase)) (require 'sgml-mode) (require 'js) (require 'css-mode) @@ -73,7 +74,9 @@ code(); (defconst mhtml--crucial-variable-prefix (regexp-opt '("comment-" "uncomment-" "electric-indent-" - "smie-" "forward-sexp-function" "completion-" "major-mode")) + "smie-" "forward-sexp-function" "completion-" "major-mode" + "adaptive-fill-" "fill-" "normal-auto-fill-function" + "paragraph-")) "Regexp matching the prefix of \"crucial\" buffer-locals we want to capture.") (defconst mhtml--variable-prefix @@ -157,54 +160,6 @@ code(); (mhtml--submode-name submode) ""))) -(defvar font-lock-beg) -(defvar font-lock-end) - -(defun mhtml--extend-font-lock-region () - "Extend the font lock region according to HTML sub-mode needs. - -This is used via `font-lock-extend-region-functions'. It ensures -that the font-lock region is extended to cover either whole -lines, or to the spot where the submode changes, whichever is -smallest." - (let ((orig-beg font-lock-beg) - (orig-end font-lock-end)) - ;; The logic here may look odd but it is needed to ensure that we - ;; do the right thing when trying to limit the search. - (save-excursion - (goto-char font-lock-beg) - ;; previous-single-property-change starts by looking at the - ;; previous character, but we're trying to extend a region to - ;; include just characters with the same submode as this - ;; character. - (unless (eobp) - (forward-char)) - (setq font-lock-beg (previous-single-property-change - (point) 'mhtml-submode nil - (line-beginning-position))) - (unless (eq (get-text-property font-lock-beg 'mhtml-submode) - (get-text-property orig-beg 'mhtml-submode)) - (cl-incf font-lock-beg)) - - (goto-char font-lock-end) - (unless (bobp) - (backward-char)) - (setq font-lock-end (next-single-property-change - (point) 'mhtml-submode nil - (line-beginning-position 2))) - (unless (eq (get-text-property font-lock-end 'mhtml-submode) - (get-text-property orig-end 'mhtml-submode)) - (cl-decf font-lock-end))) - - ;; Also handle the multiline property -- but handle it here, and - ;; not via font-lock-extend-region-functions, to avoid the - ;; situation where the two extension functions disagree. - ;; See bug#29159. - (font-lock-extend-region-multiline) - - (or (/= font-lock-beg orig-beg) - (/= font-lock-end orig-end)))) - (defun mhtml--submode-fontify-one-region (submode beg end &optional loudly) (if submode (mhtml--with-locals submode @@ -303,17 +258,14 @@ This is used by `mhtml--pre-command'.") sgml-syntax-propertize-rules)) (defun mhtml-syntax-propertize (start end) - ;; First remove our special settings from the affected text. They - ;; will be re-applied as needed. - (remove-list-of-text-properties start end - '(syntax-table local-map mhtml-submode)) - (goto-char start) - ;; Be sure to look back one character, because START won't yet have - ;; been propertized. - (unless (bobp) - (let ((submode (get-text-property (1- (point)) 'mhtml-submode))) - (if submode - (mhtml--syntax-propertize-submode submode end)))) + (let ((submode (get-text-property start 'mhtml-submode))) + ;; First remove our special settings from the affected text. They + ;; will be re-applied as needed. + (remove-list-of-text-properties start end + '(syntax-table local-map mhtml-submode)) + (goto-char start) + (if submode + (mhtml--syntax-propertize-submode submode end))) (sgml-syntax-propertize (point) end mhtml--syntax-propertize)) (defun mhtml-indent-line () @@ -352,6 +304,17 @@ This is used by `mhtml--pre-command'.") (flyspell-generic-progmode-verify) t))) +;; Support for hideshow.el (see `hs-special-modes-alist'). +(defun mhtml-forward (arg) + "Move point forward past a structured expression. +If point is on a tag, move to the end of the tag. +Otherwise, this calls `forward-sexp'. +Prefix arg specifies how many times to move (default 1)." + (interactive "P") + (pcase (get-text-property (point) 'mhtml-submode) + ('nil (sgml-skip-tag-forward arg)) + (submode (forward-sexp arg)))) + ;;;###autoload (define-derived-mode mhtml-mode html-mode '((sgml-xml-mode "XHTML+" "HTML+") (:eval (mhtml--submode-lighter))) @@ -364,8 +327,6 @@ the rules from `css-mode'." (setq-local syntax-propertize-function #'mhtml-syntax-propertize) (setq-local font-lock-fontify-region-function #'mhtml--submode-fontify-region) - (setq-local font-lock-extend-region-functions - '(mhtml--extend-font-lock-region)) ;; Attach this to both pre- and post- hooks just in case it ever ;; changes a key binding that might be accessed from the menu bar. @@ -383,6 +344,18 @@ the rules from `css-mode'." ;: Hack (js--update-quick-match-re) + ;; Setup the appropriate js-mode value of auto-fill-function. + (setf (mhtml--submode-crucial-captured-locals mhtml--js-submode) + (push (cons 'auto-fill-function + (if (and (boundp 'auto-fill-function) auto-fill-function) + #'js-do-auto-fill + nil)) + (mhtml--submode-crucial-captured-locals mhtml--js-submode))) + + ;; This mode might be using CC Mode's filling functionality. + (c-foreign-init-lit-pos-cache) + (add-hook 'before-change-functions #'c-foreign-truncate-lit-pos-cache nil t) + ;; This is sort of a prog-mode as well as a text mode. (run-hooks 'prog-mode-hook)) diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el index 62e8b1f0934..bb2582cf7a2 100644 --- a/lisp/textmodes/nroff-mode.el +++ b/lisp/textmodes/nroff-mode.el @@ -50,7 +50,6 @@ (let ((map (make-sparse-keymap)) (menu-map (make-sparse-keymap))) (define-key map "\t" 'tab-to-tab-stop) - (define-key map "\es" 'center-line) (define-key map "\e?" 'nroff-count-text-lines) (define-key map "\n" 'nroff-electric-newline) (define-key map "\en" 'nroff-forward-text-line) diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el index c2b7b66b9f7..b357bbbbe97 100644 --- a/lisp/textmodes/page-ext.el +++ b/lisp/textmodes/page-ext.el @@ -429,20 +429,19 @@ REVERSE (non-nil means reverse order), BEG and END (region to sort)." ;; NEXTRECFUN is called with point at the end of the ;; previous record. It moves point to the start of the ;; next record. - (function (lambda () - (re-search-forward page-delimiter nil t) - (skip-chars-forward " \t\n") - )) + (lambda () + (re-search-forward page-delimiter nil t) + (skip-chars-forward " \t\n")) ;; ENDRECFUN is called with point within the record. ;; It should move point to the end of the record. - (function (lambda () - (if (re-search-forward - page-delimiter - nil - t) - (goto-char (match-beginning 0)) - (goto-char (point-max)))))))) + (lambda () + (if (re-search-forward + page-delimiter + nil + t) + (goto-char (match-beginning 0)) + (goto-char (point-max))))))) (define-obsolete-function-alias 'sort-pages-buffer #'pages-sort-buffer "27.1") (defun pages-sort-buffer (&optional reverse) diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 99c3e471241..b0975291428 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -168,7 +168,7 @@ to obtain the value of this variable." (defcustom sentence-end-base "[.?!…‽][]\"'”’)}»›]*" "Regexp matching the basic end of a sentence, not including following space." :group 'paragraphs - :type 'string + :type 'regexp :version "25.1") (put 'sentence-end-base 'safe-local-variable 'stringp) @@ -371,33 +371,50 @@ See `forward-paragraph' for more information." (defun mark-paragraph (&optional arg allow-extend) "Put point at beginning of this paragraph, mark at end. -The paragraph marked is the one that contains point or follows point. +The paragraph marked is the one that contains point or follows +point. -With argument ARG, puts mark at end of a following paragraph, so that -the number of paragraphs marked equals ARG. +With argument ARG, puts mark at the end of this or a following +paragraph, so that the number of paragraphs marked equals ARG. -If ARG is negative, point is put at end of this paragraph, mark is put -at beginning of this or a previous paragraph. +If ARG is negative, point is put at the end of this paragraph, +mark is put at the beginning of this or a previous paragraph. Interactively (or if ALLOW-EXTEND is non-nil), if this command is -repeated or (in Transient Mark mode) if the mark is active, -it marks the next ARG paragraphs after the ones already marked." - (interactive "p\np") - (unless arg (setq arg 1)) - (when (zerop arg) - (error "Cannot mark zero paragraphs")) - (cond ((and allow-extend - (or (and (eq last-command this-command) (mark t)) - (and transient-mark-mode mark-active))) - (set-mark - (save-excursion - (goto-char (mark)) - (forward-paragraph arg) - (point)))) - (t - (forward-paragraph arg) - (push-mark nil t t) - (backward-paragraph arg)))) +repeated or (in Transient Mark mode) if the mark is active, it +marks the next ARG paragraphs after the region already marked. +This also means when activating the mark immediately before using +this command, the current paragraph is only marked from point." + (interactive "P\np") + (let ((numeric-arg (prefix-numeric-value arg))) + (cond ((zerop numeric-arg)) + ((and allow-extend + (or (and (eq last-command this-command) mark-active) + (region-active-p))) + (if arg + (setq arg numeric-arg) + (if (< (mark) (point)) + (setq arg -1) + (setq arg 1))) + (set-mark + (save-excursion + (goto-char (mark)) + (forward-paragraph arg) + (point)))) + ;; don't activate the mark when at eob + ((and (eobp) (> numeric-arg 0))) + (t + (unless (save-excursion + (forward-line 0) + (looking-at paragraph-start)) + (backward-paragraph (cond ((> numeric-arg 0) 1) + ((< numeric-arg 0) -1) + (t 0)))) + (push-mark + (save-excursion + (forward-paragraph numeric-arg) + (point)) + t t))))) (defun kill-paragraph (arg) "Kill forward to end of paragraph. diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index 7a82f8f0e6a..5216812b587 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el @@ -1,4 +1,4 @@ -;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model +;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model -*- lexical-binding: t -*- ;; Copyright (C) 1985, 1994, 2001-2020 Free Software Foundation, Inc. diff --git a/lisp/textmodes/po.el b/lisp/textmodes/po.el index d5645e86304..29c6d3f4608 100644 --- a/lisp/textmodes/po.el +++ b/lisp/textmodes/po.el @@ -1,4 +1,4 @@ -;;; po.el --- basic support of PO translation files +;;; po.el --- basic support of PO translation files -*- lexical-binding:t -*- ;; Copyright (C) 1995-1998, 2000-2020 Free Software Foundation, Inc. diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el index 8d8223a7326..888c310b4a1 100644 --- a/lisp/textmodes/refer.el +++ b/lisp/textmodes/refer.el @@ -249,9 +249,9 @@ found on the last `refer-find-entry' or `refer-find-next-entry'." (forward-paragraph 1) (setq end (point)) (setq found - (refer-every (function (lambda (keyword) - (goto-char begin) - (re-search-forward keyword end t))) + (refer-every (lambda (keyword) + (goto-char begin) + (re-search-forward keyword end t)) keywords-list)) (if (not found) (progn @@ -336,9 +336,9 @@ found on the last `refer-find-entry' or `refer-find-next-entry'." (list (expand-file-name (if (eq major-mode 'bibtex-mode) (read-file-name - (format ".bib file (default %s): " - (file-name-nondirectory - (buffer-file-name))) + (format-prompt ".bib file" + (file-name-nondirectory + (buffer-file-name))) (file-name-directory (buffer-file-name)) (file-name-nondirectory (buffer-file-name)) t) diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index b79bb292c8a..4c780d8d8c3 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -861,9 +861,7 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window." (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*" (line-beginning-position)) (reftex-this-word "-a-zA-Z0-9_*.:"))) - (label (completing-read (if default - (format "Label (default %s): " default) - "Label: ") + (label (completing-read (format-prompt "Label" default) docstruct (lambda (x) (stringp (car x))) t nil nil default)) diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index ca92541331e..c9fd19d2324 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -925,7 +925,7 @@ DOWNCASE t: Downcase words before using them." "\\<label[[:space:]]*=[[:space:]]*" ;; Match the label value; braces around the value are ;; optional. - "{?\\(?1:[^] ,}\r\n\t%]+\\)}?" + "{?\\(?1:[^] ,}\r\n\t%]+\\)" ;; We are done. Just search until the next closing bracket "[^]]*\\]")) "List of regexps matching \\label definitions. @@ -2100,6 +2100,8 @@ construct: \\bbb [xxx] {aaa}." "Hook which is being run when loading reftex.el." :group 'reftex-miscellaneous-configurations :type 'hook) +(make-obsolete-variable 'reftex-load-hook + "use `with-eval-after-load' instead." "28.1") (defcustom reftex-mode-hook nil "Hook which is being run when turning on RefTeX mode." diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 542f1fef14e..4071c0dd074 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -2371,7 +2371,7 @@ what in fact did happen. Check if the bug is reproducible with an up-to-date version of RefTeX available from https://www.gnu.org/software/auctex/. -If the bug is triggered by a specific \(La)TeX file, you should try +If the bug is triggered by a specific (La)TeX file, you should try to produce a minimal sample file showing the problem and include it in your report. diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el index 836dfb4a538..7bc7dc1762e 100644 --- a/lisp/textmodes/remember.el +++ b/lisp/textmodes/remember.el @@ -5,7 +5,7 @@ ;; Author: John Wiegley <johnw@gnu.org> ;; Maintainer: emacs-devel@gnu.org ;; Created: 29 Mar 1999 -;; Version: 2.0 +;; Old-Version: 2.0 ;; Keywords: data memory todo pim ;; URL: http://gna.org/projects/remember-el/ @@ -181,6 +181,7 @@ (defconst remember-version "2.0" "This version of remember.") +(make-obsolete-variable 'remember-version nil "28.1") (defgroup remember nil "A mode to remember information." @@ -486,9 +487,6 @@ Most useful for remembering things from other applications." (interactive) (remember-region (point-min) (point-max))) -;; Org needs this -(define-obsolete-function-alias 'remember-buffer 'remember-finalize "23.1") - (defun remember-destroy () "Destroy the current *Remember* buffer." (interactive) diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index 5fadec491a5..adda28cb81b 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el @@ -2363,7 +2363,7 @@ If user selects enumerations, a further prompt is given. User need to input a starting item, for example 'e' for 'A)' style. The position is also arranged by `rst-insert-list-new-tag'." (let* ((itemstyle (completing-read - "Select preferred item style [#.]: " + (format-prompt "Select preferred item style" "#.") rst-initial-items nil t nil nil "#.")) (cnt (if (string-match (rst-re 'cntexp-tag) itemstyle) (match-string 0 itemstyle))) @@ -2371,21 +2371,23 @@ also arranged by `rst-insert-list-new-tag'." (save-match-data (cond ((equal cnt "a") - (let ((itemno (read-string "Give starting value [a]: " - nil nil "a"))) + (let ((itemno (read-string + (format-prompt "Give starting value" "a") + nil nil "a"))) (downcase (substring itemno 0 1)))) ((equal cnt "A") - (let ((itemno (read-string "Give starting value [A]: " - nil nil "A"))) + (let ((itemno (read-string + (format-prompt "Give starting value" "A") + nil nil "A"))) (upcase (substring itemno 0 1)))) ((equal cnt "I") - (let ((itemno (read-number "Give starting value [1]: " 1))) + (let ((itemno (read-number "Give starting value: " 1))) (rst-arabic-to-roman itemno))) ((equal cnt "i") - (let ((itemno (read-number "Give starting value [1]: " 1))) + (let ((itemno (read-number "Give starting value: " 1))) (downcase (rst-arabic-to-roman itemno)))) ((equal cnt "1") - (let ((itemno (read-number "Give starting value [1]: " 1))) + (let ((itemno (read-number "Give starting value: " 1))) (number-to-string itemno))))))) (if no (setq itemstyle (replace-match no t t itemstyle))) @@ -2860,7 +2862,7 @@ file-write hook to always make it up-to-date automatically." ;; FIXME: Updating the toc on saving would be nice. However, this doesn't work ;; correctly: ;; -;; (add-hook 'write-contents-hooks 'rst-toc-update-fun) +;; (add-hook 'write-contents-functions 'rst-toc-update-fun) ;; (defun rst-toc-update-fun () ;; ;; Disable undo for the write file hook. ;; (let ((buffer-undo-list t)) (rst-toc-update) )) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 6152a8ad0a7..f3d8695e248 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -46,7 +46,8 @@ (defcustom sgml-basic-offset 2 "Specifies the basic indentation level for `sgml-indent-line'." - :type 'integer) + :type 'integer + :safe #'integerp) (defcustom sgml-attribute-offset 0 "Specifies a delta for attribute indentation in `sgml-indent-line'. @@ -286,7 +287,10 @@ separated by a space." (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*") (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*") (defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)")) -(defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*") +(defconst sgml-attrs-re + ;; This pattern cannot begin with a character matched by the end of + ;; `sgml-name-re' above. + "\\(?:[^_.:\"'/><[:alnum:]-]\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?") (defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re) "Regular expression that matches a non-empty start tag. Any terminating `>' or `/' is not matched.") @@ -775,7 +779,7 @@ If you like tags and attributes in uppercase, customize (setq sgml-tag-last (completing-read (if (> (length sgml-tag-last) 0) - (format "Tag (default %s): " sgml-tag-last) + (format-prompt "Tag" sgml-tag-last) "Tag: ") sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last))) ?< str | @@ -874,9 +878,7 @@ With prefix argument, only self insert." (list (let ((def (save-excursion (if (eq (following-char) ?<) (forward-char)) (sgml-beginning-of-tag)))) - (completing-read (if def - (format "Tag (default %s): " def) - "Tag: ") + (completing-read (format-prompt "Tag" def) sgml-tag-alist nil nil nil 'sgml-tag-history def)))) (or (and tag (> (length tag) 0)) @@ -1186,10 +1188,9 @@ and move to the line in the SGML document that caused it." (or sgml-saved-validate-command (concat sgml-validate-command " " - (shell-quote-argument - (let ((name (buffer-file-name))) - (and name - (file-name-nondirectory name))))))))) + (when-let ((name (buffer-file-name))) + (shell-quote-argument + (file-name-nondirectory name)))))))) (setq sgml-saved-validate-command command) (save-some-buffers (not compilation-ask-about-save) nil) (compilation-start command)) @@ -1803,6 +1804,7 @@ This takes effect when first loading the library.") (define-key map "\C-c\C-cc" 'html-checkboxes) (define-key map "\C-c\C-cl" 'html-list-item) (define-key map "\C-c\C-ch" 'html-href-anchor) + (define-key map "\C-c\C-cf" 'html-href-anchor-file) (define-key map "\C-c\C-cn" 'html-name-anchor) (define-key map "\C-c\C-c#" 'html-id-anchor) (define-key map "\C-c\C-ci" 'html-image) @@ -1815,6 +1817,7 @@ This takes effect when first loading the library.") (define-key map "\C-cc" 'html-checkboxes) (define-key map "\C-cl" 'html-list-item) (define-key map "\C-ch" 'html-href-anchor) + (define-key map "\C-cf" 'html-href-anchor-file) (define-key map "\C-cn" 'html-name-anchor) (define-key map "\C-c#" 'html-id-anchor) (define-key map "\C-ci" 'html-image) @@ -1842,15 +1845,16 @@ This takes effect when first loading the library.") (define-key menu-map "\n" '("Line Break" . html-line)) (define-key menu-map "\r" '("Paragraph" . html-paragraph)) (define-key menu-map "i" '("Image" . html-image)) - (define-key menu-map "h" '("Href Anchor" . html-href-anchor)) + (define-key menu-map "h" '("Href Anchor URL" . html-href-anchor)) + (define-key menu-map "f" '("Href Anchor File" . html-href-anchor-file)) (define-key menu-map "n" '("Name Anchor" . html-name-anchor)) (define-key menu-map "#" '("ID Anchor" . html-id-anchor)) map) "Keymap for commands for use in HTML mode.") (defvar html-face-tag-alist - '((bold . "b") - (italic . "i") + '((bold . "strong") + (italic . "em") (underline . "u") (mode-line . "rev")) "Value of `sgml-face-tag-alist' for HTML mode.") @@ -2360,7 +2364,7 @@ have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6> <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are ignored unless the text is <pre>preformatted.</pre> Text can be marked as -<b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-o or +<strong>bold</strong>, <em>italic</em> or <u>underlined</u> using the normal M-o or Edit/Text Properties/Face commands. Pages can have <a name=\"SOMENAME\">named points</a> and can link other points @@ -2450,6 +2454,11 @@ HTML Autoview mode is a buffer-local minor mode for use with ;; '(setq input "http:") "<a href=\"" str "\">" _ "</a>") +(define-skeleton html-href-anchor-file + "HTML anchor tag with href attribute (from a local file)." + (file-relative-name (read-file-name "File name: ") default-directory) + "<a href=\"" str "\">" _ "</a>") + (define-skeleton html-name-anchor "HTML anchor tag with name attribute." "Name: " diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index bd2cac7aebb..25aa58046f4 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -339,8 +339,8 @@ ;; When using `table-cell-map-hook' do not use `local-set-key'. ;; ;; (add-hook 'table-cell-map-hook -;; (function (lambda () -;; (local-set-key [<key sequence>] '<function>)))) +;; (lambda () +;; (local-set-key [<key sequence>] '<function>))) ;; ;; Adding the above to your init file is a common way to customize a ;; mode specific keymap. However it does not work for this package. @@ -349,8 +349,8 @@ ;; explicitly. The correct way of achieving above task is: ;; ;; (add-hook 'table-cell-map-hook -;; (function (lambda () -;; (define-key table-cell-map [<key sequence>] '<function>)))) +;; (lambda () +;; (define-key table-cell-map [<key sequence>] '<function>))) ;; ;; ----- ;; Menu: @@ -793,6 +793,8 @@ simply by any key input." "List of functions to be called after the table is first loaded." :type 'hook :group 'table-hooks) +(make-obsolete-variable 'table-load-hook + "use `with-eval-after-load' instead." "28.1") (defcustom table-point-entered-cell-hook nil "List of functions to be called after point entered a table cell." @@ -1822,11 +1824,11 @@ See `table-insert-row' and `table-insert-column'." (list (intern (let ((completion-ignore-case t) (default (car table-insert-row-column-history))) (downcase (completing-read - (format "Insert %s row%s/column%s (default %s): " - (if (> n 1) (format "%d" n) "a") - (if (> n 1) "s" "") - (if (> n 1) "s" "") - default) + (format-prompt + "Insert %s row%s/column%s" default + (if (> n 1) (format "%d" n) "a") + (if (> n 1) "s" "") + (if (> n 1) "s" "")) '(("row") ("column")) nil t nil 'table-insert-row-column-history default)))) n))) @@ -2532,7 +2534,7 @@ DIRECTION is one of symbols; right, left, above or below." (caar direction-list))) (completion-ignore-case t)) (intern (downcase (completing-read - (format "Span into (default %s): " default-direction) + (format-prompt "Span into" default-direction) direction-list nil t nil 'table-cell-span-direction-history default-direction)))))) (unless (memq direction '(right left above below)) @@ -2695,7 +2697,7 @@ Creates a cell on the left and a cell on the right of the current point location ("Title" ("Split" . "split") ("Left" . "left") ("Right" . "right")))) (downcase (completing-read - (format "Existing cell contents to (default %s): " default) + (format-prompt "Existing cell contents to" default) '(("split") ("left") ("right")) nil t nil 'table-cell-split-contents-to-history default))))))) (unless (eq contents-to 'split) @@ -2767,7 +2769,7 @@ ORIENTATION is a symbol either horizontally or vertically." (completion-ignore-case t) (default (car table-cell-split-orientation-history))) (intern (downcase (completing-read - (format "Split orientation (default %s): " default) + (format-prompt "Split orientation" default) '(("horizontally") ("vertically")) nil t nil 'table-cell-split-orientation-history default)))))) (unless (memq orientation '(horizontally vertically)) @@ -2787,7 +2789,7 @@ WHAT is a symbol `cell', `row' or `column'. JUSTIFY is a symbol (completion-ignore-case t) (default (car table-target-history))) (intern (downcase (completing-read - (format "Justify what (default %s): " default) + (format-prompt "Justify what" default) '(("cell") ("row") ("column")) nil t nil 'table-target-history default)))) (table--query-justification))) @@ -2927,7 +2929,7 @@ buffer, and leaves the previous contents of the buffer untouched. References used for this implementation: HTML: - URL `http://www.w3.org' + URL `https://www.w3.org' LaTeX: URL `http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Tables.html' @@ -2941,7 +2943,7 @@ CALS (DocBook DTD): (completion-ignore-case t) (default (car table-source-language-history)) (language (downcase (completing-read - (format "Language (default %s): " default) + (format-prompt "Language" default) table-source-languages nil t nil 'table-source-language-history default)))) (list @@ -3207,11 +3209,7 @@ CALS (DocBook DTD): (while (and (re-search-forward "$" nil t) (not (eobp))) (insert "<br />") - (forward-char 1))) - (unless (and table-html-delegate-spacing-to-user-agent - (progn - (goto-char (point-min)) - (looking-at "\\s *\\'"))))) + (forward-char 1)))) ((eq language 'cals) (table--remove-eol-spaces (point-min) (point-max)) (if (re-search-forward "\\s +\\'" nil t) @@ -3281,7 +3279,7 @@ Currently this method is for LaTeX only." (with-temp-buffer (insert line) (goto-char (point-min)) - (while (re-search-forward "\\([#$~_^%{}]\\)\\|\\(\\\\\\)\\|\\([<>|]\\)" nil t) + (while (re-search-forward "\\([#$~_^%{}&]\\)\\|\\(\\\\\\)\\|\\([<>|]\\)" nil t) (if (match-beginning 1) (save-excursion (goto-char (match-beginning 1)) @@ -3368,7 +3366,7 @@ Example: (let* ((completion-ignore-case t) (default (car table-sequence-justify-history))) (intern (downcase (completing-read - (format "Justify (default %s): " default) + (format-prompt "Justify" default) '(("left") ("center") ("right")) nil t nil 'table-sequence-justify-history default))))))) (unless (or (called-interactively-p 'interactive) (table--probe-cell)) @@ -3505,9 +3503,9 @@ column must consists from cells of same width." (let ((cell-list (table--vertical-cell-list 'top-to-bottom))) (unless (and (table--uniform-list-p - (mapcar (function (lambda (cell) (car (table--get-coordinate (car cell))))) cell-list)) + (mapcar (lambda (cell) (car (table--get-coordinate (car cell)))) cell-list)) (table--uniform-list-p - (mapcar (function (lambda (cell) (car (table--get-coordinate (cdr cell))))) cell-list))) + (mapcar (lambda (cell) (car (table--get-coordinate (cdr cell)))) cell-list))) (error "Cells in this column are not in uniform width")) (unless lu-coord (setq lu-coord (table--get-coordinate (caar cell-list)))) @@ -3670,7 +3668,7 @@ companion command to `table-capture' this way. (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) 'left (intern (downcase (completing-read - (format "Justify (default %s): " default) + (format-prompt "Justify" default) '(("left") ("center") ("right")) nil t nil 'table-capture-justify-history default))))) (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) "1" @@ -4255,9 +4253,8 @@ cache buffer into the designated cell in the table buffer." PROMPT-HISTORY is a cons cell which car is the prompt string and the cdr is the history symbol." (let ((default (car (symbol-value (cdr prompt-history))))) - (read-from-minibuffer - (format "%s (default %s): " (car prompt-history) default) - "" nil nil (cdr prompt-history) default)) + (read-from-minibuffer (format-prompt (car prompt-history) default) + "" nil nil (cdr prompt-history) default)) (car (symbol-value (cdr prompt-history)))) (defun table--buffer-substring-and-trim (beg end) @@ -4314,7 +4311,7 @@ Returns the coordinate of the final point location." (let* ((completion-ignore-case t) (default (car table-justify-history))) (intern (downcase (completing-read - (format "Justify (default %s): " default) + (format-prompt "Justify" default) '(("left") ("center") ("right") ("top") ("middle") ("bottom") ("none")) nil t nil 'table-justify-history default))))) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 0e28756ea75..37ab11ad89f 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -224,7 +224,7 @@ Should show the queue(s) that \\[tex-print] puts jobs on." :group 'tex-view) ;;;###autoload -(defcustom tex-default-mode 'latex-mode +(defcustom tex-default-mode #'latex-mode "Mode to enter for a new file that might be either TeX or LaTeX. This variable is used when it can't be determined whether the file is plain TeX or LaTeX or what because the file contains no commands. @@ -422,7 +422,7 @@ An alternative value is \" . \", if you use a font with a narrow period." (push (cons "--" (match-beginning 0)) menu)) ;; Sort in increasing buffer position order. - (sort menu (function (lambda (a b) (< (cdr a) (cdr b)))))))) + (sort menu (lambda (a b) (< (cdr a) (cdr b))))))) ;;;; ;;;; Outline support @@ -465,7 +465,7 @@ An alternative value is \" . \", if you use a font with a narrow period." ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep) ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep) ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face) -; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep)) +; ("^[ \t\n]*\\\\def[\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep)) ; ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>. ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" ; 2 font-lock-function-name-face) @@ -593,7 +593,7 @@ An alternative value is \" . \", if you use a font with a narrow period." ;; Miscellany. (slash "\\\\") (opt " *\\(\\[[^]]*\\] *\\)*") - (args "\\(\\(?:[^{}&\\]+\\|\\\\.\\|{[^}]*}\\)+\\)") + (args "\\(\\(?:[^${}&\\]+\\|\\\\.\\|{[^}]*}\\)+\\)") (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) (list ;; @@ -668,7 +668,9 @@ An alternative value is \" . \", if you use a font with a narrow period." "Default expressions to highlight in TeX modes.") (defvar tex-verbatim-environments - '("verbatim" "verbatim*")) + '("verbatim" "verbatim*" + "Verbatim" ;; From "fancyvrb" + )) (put 'tex-verbatim-environments 'safe-local-variable (lambda (x) (not (memq nil (mapcar #'stringp x))))) @@ -966,7 +968,7 @@ Inherits `shell-mode-map' with a few additions.") ;; This would be a lot simpler if we just used a regexp search, ;; but then it would be too slow. -(defun tex-guess-mode () +(defun tex--guess-mode () (let ((mode tex-default-mode) slash comment) (save-excursion (goto-char (point-min)) @@ -983,52 +985,40 @@ Inherits `shell-mode-map' with a few additions.") (regexp-opt '("documentstyle" "documentclass" "begin" "subsection" "section" "part" "chapter" "newcommand" - "renewcommand" "RequirePackage") 'words) + "renewcommand" "RequirePackage") + 'words) "\\|NeedsTeXFormat{LaTeX"))) (if (and (looking-at "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") ;; SliTeX is almost never used any more nowadays. (tex-executable-exists-p slitex-run-command)) - 'slitex-mode - 'latex-mode) - 'plain-tex-mode)))) - (funcall mode))) + #'slitex-mode + #'latex-mode) + #'plain-tex-mode)))) + mode)) ;; `tex-mode' plays two roles: it's the parent of several sub-modes ;; but it's also the function that chooses between those submodes. ;; To tell the difference between those two cases where the function ;; might be called, we check `delay-mode-hooks'. -(define-derived-mode tex-mode text-mode "generic-TeX" - (tex-common-initialization)) -;; We now move the function and define it again. This gives a warning -;; in the byte-compiler :-( but it's difficult to avoid because -;; `define-derived-mode' will necessarily define the function once -;; and we need to define it a second time for `autoload' to get the -;; proper docstring. -(defalias 'tex-mode-internal (symbol-function 'tex-mode)) - -;; Suppress the byte-compiler warning about multiple definitions. -;; This is a) ugly, and b) cheating, but this was the last -;; remaining warning from byte-compiling all of Emacs... -(eval-when-compile - (if (boundp 'byte-compile-function-environment) - (setq byte-compile-function-environment - (delq (assq 'tex-mode byte-compile-function-environment) - byte-compile-function-environment)))) - ;;;###autoload -(defun tex-mode () +(define-derived-mode tex-mode text-mode "generic-TeX" "Major mode for editing files of input for TeX, LaTeX, or SliTeX. +This is the shared parent mode of several submodes. Tries to determine (by looking at the beginning of the file) whether this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode', -`latex-mode', or `slitex-mode', respectively. If it cannot be determined, +`latex-mode', or `slitex-mode', accordingly. If it cannot be determined, such as if there are no commands in the file, the value of `tex-default-mode' says which mode to use." - (interactive) - (if delay-mode-hooks - ;; We're called from one of the children already. - (tex-mode-internal) - (tex-guess-mode))) + (tex-common-initialization)) + +(advice-add 'tex-mode :around #'tex--redirect-to-submode) +(defun tex--redirect-to-submode (orig-fun) + "Redirect to one of the submodes when called directly." + (funcall (if delay-mode-hooks + ;; We're called from one of the children already. + orig-fun + (tex--guess-mode)))) ;; The following three autoloaded aliases appear to conflict with ;; AUCTeX. However, even though AUCTeX uses the mixed case variants @@ -1037,6 +1027,10 @@ says which mode to use." ;; AUCTeX to provide a fully functional user-level replacement. So ;; these aliases should remain as they are, in particular since AUCTeX ;; users are likely to use them. +;; Note from Stef: I don't understand the above explanation, the only +;; justification I can find to keep those confusing aliases is for those +;; users who may have files annotated with -*- LaTeX -*- (e.g. because they +;; received them from someone using AUCTeX). ;;;###autoload (defalias 'TeX-mode 'tex-mode) @@ -1252,10 +1246,10 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "") ("%" . "$")))) ;; A line containing just $$ is treated as a paragraph separator. - (setq-local paragraph-start "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") + (setq-local paragraph-start "[ \t]*$\\|[\f\\%]\\|[ \t]*\\$\\$") ;; A line starting with $$ starts a paragraph, ;; but does not separate paragraphs if it has more stuff on it. - (setq-local paragraph-separate "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") + (setq-local paragraph-separate "[ \t]*$\\|[\f\\%]\\|[ \t]*\\$\\$[ \t]*$") (setq-local add-log-current-defun-function #'tex-current-defun-name) (setq-local comment-start "%") (setq-local comment-add 1) @@ -2301,9 +2295,6 @@ FILE is typically the output DVI or PDF file." (setq uptodate nil))))) uptodate))) - -(autoload 'format-spec "format-spec") - (defvar tex-executable-cache nil) (defun tex-executable-exists-p (name) "Like `executable-find' but with a cache." @@ -3550,6 +3541,8 @@ There might be text before point." (process-send-region tex-chktex--process (point-min) (point-max)) (process-send-eof tex-chktex--process)))) +(make-obsolete-variable 'tex-mode-load-hook + "use `with-eval-after-load' instead." "28.1") (run-hooks 'tex-mode-load-hook) (provide 'tex-mode) diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 438cb7798a1..b3bc634de9b 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -482,6 +482,13 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") (define-key map "\C-c\C-ce" 'texinfo-insert-@end) (define-key map "\C-c\C-cd" 'texinfo-insert-@dfn) (define-key map "\C-c\C-cc" 'texinfo-insert-@code) + + ;; bindings for environment movement + (define-key map "\C-c." 'texinfo-to-environment-bounds) + (define-key map "\C-c\C-c\C-f" 'texinfo-next-environment-end) + (define-key map "\C-c\C-c\C-b" 'texinfo-previous-environment-end) + (define-key map "\C-c\C-c\C-n" 'texinfo-next-environment-start) + (define-key map "\C-c\C-c\C-p" 'texinfo-previous-environment-start) map)) (easy-menu-define texinfo-mode-menu @@ -958,6 +965,12 @@ to jump to the corresponding spot in the Texinfo source file." :type 'string :group 'texinfo) +(defcustom texinfo-texi2dvi-options "" + "Command line options for `texinfo-texi2dvi-command'." + :type 'string + :group 'texinfo + :version "28.1") + (defcustom texinfo-tex-command "tex" "Command used by `texinfo-tex-region' to run TeX on a region." :type 'string @@ -1002,9 +1015,10 @@ The value of `texinfo-tex-trailer' is appended to the temporary file after the r (interactive) (require 'tex-mode) (let ((tex-command texinfo-texi2dvi-command) - ;; Disable tex-start-options-string. texi2dvi would not - ;; understand anything specified here. - (tex-start-options-string "")) + (tex-start-options texinfo-texi2dvi-options) + ;; Disable tex-start-commands. texi2dvi would not understand + ;; anything specified here. + (tex-start-commands "")) (tex-buffer))) (defun texinfo-texindex () @@ -1065,6 +1079,70 @@ You are prompted for the job number (use a number shown by a previous ;; job-number"\n")) (tex-recenter-output-buffer nil)) +(defun texinfo-to-environment-bounds () + "Move point alternately to the start and end of a Texinfo environment. +Do nothing when outside of an environment. This command does not +handle nested environments." + (interactive) + (cond ((save-excursion + (forward-line 0) + (looking-at texinfo-environment-regexp)) + (if (save-excursion + (forward-line 0) + (looking-at "^@end")) + (texinfo-previous-environment-start) + (texinfo-next-environment-end))) + ((save-excursion + (and (re-search-backward texinfo-environment-regexp nil t) + (not (looking-at "^@end")))) + (texinfo-previous-environment-start)) + ;; Otherwise, point is outside of an environment, so do nothing. + )) + +(defun texinfo-next-environment-start () + "Move forward to the beginning of a Texinfo environment." + (interactive) + (if (looking-at texinfo-environment-regexp) + (forward-line 1)) + (while (and (re-search-forward texinfo-environment-regexp nil t) + (save-excursion + (goto-char (match-beginning 0)) + (looking-at "@end")))) + (if (save-excursion + (forward-line 0) + (looking-at texinfo-environment-regexp)) + (forward-line 0))) + +(defun texinfo-previous-environment-start () + "Move back to the beginning of the previous Texinfo environment." + (interactive) + (while (and (re-search-backward texinfo-environment-regexp nil t) + (save-excursion + (goto-char (match-beginning 0)) + (looking-at "@end"))))) + +(defun texinfo-next-environment-end () + "Move forward to the beginning of the next @end line of an environment." + (interactive) + (if (looking-at "^@end") + (forward-line 1)) + (while (and (re-search-forward texinfo-environment-regexp nil t) + (save-excursion + (goto-char (match-beginning 0)) + (not (looking-at "^@end"))))) + (if (save-excursion + (forward-line 0) + (looking-at "^@end")) + (forward-line 0))) + +(defun texinfo-previous-environment-end () + "Move backward to the beginning of the next @end line of an environment." + (interactive) + (while (and (re-search-backward texinfo-environment-regexp nil t) + (save-excursion + (goto-char (match-beginning 0)) + (not (looking-at "@end")))))) + (provide 'texinfo) ;;; texinfo.el ends here diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 25f37ffa23d..398f7fdc232 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -67,7 +67,7 @@ matching the white space). The pattern is matched case-sensitive regardless of the value of `case-fold-search' setting." :version "25.1" :group 'tildify - :type 'string + :type 'regexp :safe t) (defcustom tildify-pattern-alist () @@ -417,7 +417,7 @@ of a space at point. The regexp is always case sensitive, regardless of the current `case-fold-search' setting." :version "25.1" :group 'tildify - :type 'string) + :type 'regexp) (defcustom tildify-space-predicates '(tildify-space-region-predicate) "A list of predicate functions for `tildify-space' function." |