summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/autoinsert.el10
-rw-r--r--lisp/files.el4
-rw-r--r--lisp/gnus/gnus-score.el6
-rw-r--r--lisp/mpc.el30
-rw-r--r--lisp/net/trampver.el3
-rw-r--r--lisp/newcomment.el2
-rw-r--r--lisp/progmodes/cc-fonts.el149
-rw-r--r--lisp/progmodes/cc-langs.el11
-rw-r--r--lisp/progmodes/cperl-mode.el2
-rw-r--r--lisp/progmodes/idlwave.el2
-rw-r--r--lisp/term/xterm.el35
-rw-r--r--lisp/textmodes/reftex-ref.el2
-rw-r--r--lisp/thingatpt.el30
13 files changed, 156 insertions, 130 deletions
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index 2820c8a9afa..a43e068a4dc 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -141,14 +141,14 @@ If this contains a %s, that will be replaced by the matching rule."
"
.\\\" You may distribute this file under the terms of the GNU Free
.\\\" Documentation License.
-.TH " (file-name-base)
+.TH " (file-name-base (buffer-file-name))
" " (file-name-extension (buffer-file-name))
" " (format-time-string "%Y-%m-%d ")
"\n.SH NAME\n"
- (file-name-base)
+ (file-name-base (buffer-file-name))
" \\- " str
"\n.SH SYNOPSIS
-.B " (file-name-base)
+.B " (file-name-base (buffer-file-name))
"\n"
_
"
@@ -211,7 +211,7 @@ If this contains a %s, that will be replaced by the matching rule."
\(provide '"
- (file-name-base)
+ (file-name-base (buffer-file-name))
")
\;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n")
(("\\.texi\\(nfo\\)?\\'" . "Texinfo file skeleton")
@@ -219,7 +219,7 @@ If this contains a %s, that will be replaced by the matching rule."
"\\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename "
- (file-name-base) ".info\n"
+ (file-name-base (buffer-file-name)) ".info\n"
"@settitle " str "
@c %**end of header
@copying\n"
diff --git a/lisp/files.el b/lisp/files.el
index c55c8097c16..fe7cb1a8a94 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4479,8 +4479,8 @@ extension, the value is \"\"."
"")))))
(defun file-name-base (&optional filename)
- "Return the base name of the FILENAME: no directory, no extension.
-FILENAME defaults to `buffer-file-name'."
+ "Return the base name of the FILENAME: no directory, no extension."
+ (declare (advertised-calling-convention (filename) "27.1"))
(file-name-sans-extension
(file-name-nondirectory (or filename (buffer-file-name)))))
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 11a45dda9ad..976ac9f7f35 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -2731,8 +2731,10 @@ GROUP using BNews sys file syntax."
(insert (car sfiles))
(goto-char (point-min))
;; First remove the suffix itself.
- (when (re-search-forward (concat "." score-regexp) nil t)
- (replace-match "" t t)
+ (when (re-search-forward score-regexp nil t)
+ (unless (= (match-end 0) (match-beginning 0)) ; non-empty suffix
+ (replace-match "" t t)
+ (delete-char -1)) ; remove the "." before the suffix
(goto-char (point-min))
(if (looking-at (regexp-quote kill-dir))
;; If the file name was just "SCORE", `klen' is one character
diff --git a/lisp/mpc.el b/lisp/mpc.el
index c23d8ced716..98f4a031834 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -2403,10 +2403,38 @@ This is used so that they can be compared with `eq', which is needed for
(interactive)
(mpc-cmd-pause "0"))
+(defun mpc-read-seek (prompt)
+ "Read a seek time.
+Returns a string suitable for MPD \"seekcur\" protocol command."
+ (let* ((str (read-from-minibuffer prompt nil nil nil nil nil t))
+ (seconds "\\(?1:[[:digit:]]+\\(?:\\.[[:digit:]]*\\)?\\)")
+ (minsec (concat "\\(?2:[[:digit:]]+\\):" seconds "?"))
+ (hrminsec (concat "\\(?3:[[:digit:]]+\\):\\(?:" minsec "?\\|:\\)"))
+ time sign)
+ (setq str (string-trim str))
+ (when (memq (string-to-char str) '(?+ ?-))
+ (setq sign (string (string-to-char str)))
+ (setq str (substring str 1)))
+ (setq time
+ ;; `string-to-number' returns 0 on failure
+ (cond
+ ((string-match (concat "^" hrminsec "$") str)
+ (+ (* 3600 (string-to-number (match-string 3 str)))
+ (* 60 (string-to-number (or (match-string 2 str) "")))
+ (string-to-number (or (match-string 1 str) ""))))
+ ((string-match (concat "^" minsec "$") str)
+ (+ (* 60 (string-to-number (match-string 2 str)))
+ (string-to-number (match-string 1 str))))
+ ((string-match (concat "^" seconds "$") str)
+ (string-to-number (match-string 1 str)))
+ (t (user-error "Invalid time"))))
+ (setq time (number-to-string time))
+ (if (null sign) time (concat sign time))))
+
(defun mpc-seek-current (pos)
"Seek within current track."
(interactive
- (list (read-string "Position to go ([+-]seconds): ")))
+ (list (mpc-read-seek "Position to go ([+-][[H:]M:]seconds): ")))
(mpc-cmd-seekcur pos))
(defun mpc-toggle-play ()
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 91222bd7817..51af455e635 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -69,7 +69,8 @@
("2.2.3-24.1" . "24.1") ("2.2.3-24.1" . "24.2") ("2.2.6-24.3" . "24.3")
("2.2.9-24.4" . "24.4") ("2.2.11-24.5" . "24.5")
("2.2.13.25.1" . "25.1") ("2.2.13.25.2" . "25.2")
- ("2.2.13.25.2" . "25.3")))
+ ("2.2.13.25.2" . "25.3")
+ ("2.3.3.26.1" . "26.1")))
(add-hook 'tramp-unload-hook
(lambda ()
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 2a0f8a8ae50..2e644c3a99c 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -524,7 +524,7 @@ Ensure that `comment-normalize-vars' has been called before you use this."
;; comment-search-backward is only used to find the comment-column (in
;; comment-set-column) and to find the comment-start string (via
;; comment-beginning) in indent-new-comment-line, it should be harmless.
- (if (not (re-search-backward comment-start-skip limit t))
+ (if (not (re-search-backward comment-start-skip limit 'move))
(unless noerror (error "No comment"))
(beginning-of-line)
(let* ((end (match-end 0))
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 5aefdea3305..02b685d240d 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1026,7 +1026,8 @@ casts and declarations are fontified. Used on level 2 and higher."
(goto-char pos)))))
nil)
-(defun c-font-lock-declarators (limit list types not-top)
+(defun c-font-lock-declarators (limit list types not-top
+ &optional template-class)
;; Assuming the point is at the start of a declarator in a declaration,
;; fontify the identifier it declares. (If TYPES is set, it does this via
;; the macro `c-fontify-types-and-refs'.)
@@ -1040,6 +1041,11 @@ casts and declarations are fontified. Used on level 2 and higher."
;; non-nil, we are not at the top-level ("top-level" includes being directly
;; inside a class or namespace, etc.).
;;
+ ;; TEMPLATE-CLASS is non-nil when the declaration is in template delimiters
+ ;; and was introduced by, e.g. "typename" or "class", such that if there is
+ ;; a default (introduced by "="), it will be fontified as a type.
+ ;; E.g. "<class X = Y>".
+ ;;
;; Nil is always returned. The function leaves point at the delimiter after
;; the last declarator it processes.
;;
@@ -1112,6 +1118,13 @@ casts and declarations are fontified. Used on level 2 and higher."
(goto-char next-pos)
(setq pos nil) ; So as to terminate the enclosing `while' form.
+ (if (and template-class
+ (eq got-init ?=) ; C++ "<class X = Y>"?
+ (c-forward-token-2 1 nil limit) ; Over "="
+ (let ((c-promote-possible-types t))
+ (c-forward-type t))) ; Over "Y"
+ (setq list nil)) ; Shouldn't be needed. We can't have a list, here.
+
(when list
;; Jump past any initializer or function prototype to see if
;; there's a ',' to continue at.
@@ -1340,8 +1353,12 @@ casts and declarations are fontified. Used on level 2 and higher."
(c-backward-syntactic-ws)
(and (c-simple-skip-symbol-backward)
(looking-at c-paren-stmt-key))))
- t)))
-
+ t))
+ (template-class (and (eq context '<>)
+ (save-excursion
+ (goto-char match-pos)
+ (c-forward-syntactic-ws)
+ (looking-at c-template-typename-key)))))
;; Fix the `c-decl-id-start' or `c-decl-type-start' property
;; before the first declarator if it's a list.
;; `c-font-lock-declarators' handles the rest.
@@ -1353,10 +1370,9 @@ casts and declarations are fontified. Used on level 2 and higher."
(if (cadr decl-or-cast)
'c-decl-type-start
'c-decl-id-start)))))
-
(c-font-lock-declarators
(min limit (point-max)) decl-list
- (cadr decl-or-cast) (not toplev)))
+ (cadr decl-or-cast) (not toplev) template-class))
;; A declaration has been successfully identified, so do all the
;; fontification of types and refs that've been recorded.
@@ -1650,7 +1666,8 @@ casts and declarations are fontified. Used on level 2 and higher."
;; font-lock-keyword-face. It always returns NIL to inhibit this and
;; prevent a repeat invocation. See elisp/lispref page "Search-based
;; fontification".
- (let ((decl-search-lim (c-determine-limit 1000))
+ (let ((here (point))
+ (decl-search-lim (c-determine-limit 1000))
paren-state encl-pos token-end context decl-or-cast
start-pos top-level c-restricted-<>-arglists
c-recognize-knr-p) ; Strictly speaking, bogus, but it
@@ -1667,26 +1684,27 @@ casts and declarations are fontified. Used on level 2 and higher."
(when (or (bobp)
(memq (char-before) '(?\; ?{ ?})))
(setq token-end (point))
- (c-forward-syntactic-ws)
- ;; We're now putatively at the declaration.
- (setq start-pos (point))
- (setq paren-state (c-parse-state))
- ;; At top level or inside a "{"?
- (if (or (not (setq encl-pos
- (c-most-enclosing-brace paren-state)))
- (eq (char-after encl-pos) ?\{))
- (progn
- (setq top-level (c-at-toplevel-p))
- (let ((got-context (c-get-fontification-context
- token-end nil top-level)))
- (setq context (car got-context)
- c-restricted-<>-arglists (cdr got-context)))
- (setq decl-or-cast
- (c-forward-decl-or-cast-1 token-end context nil))
- (when (consp decl-or-cast)
- (goto-char start-pos)
- (c-font-lock-single-decl limit decl-or-cast token-end
- context top-level)))))))
+ (c-forward-syntactic-ws here)
+ (when (< (point) here)
+ ;; We're now putatively at the declaration.
+ (setq start-pos (point))
+ (setq paren-state (c-parse-state))
+ ;; At top level or inside a "{"?
+ (if (or (not (setq encl-pos
+ (c-most-enclosing-brace paren-state)))
+ (eq (char-after encl-pos) ?\{))
+ (progn
+ (setq top-level (c-at-toplevel-p))
+ (let ((got-context (c-get-fontification-context
+ token-end nil top-level)))
+ (setq context (car got-context)
+ c-restricted-<>-arglists (cdr got-context)))
+ (setq decl-or-cast
+ (c-forward-decl-or-cast-1 token-end context nil))
+ (when (consp decl-or-cast)
+ (goto-char start-pos)
+ (c-font-lock-single-decl limit decl-or-cast token-end
+ context top-level))))))))
nil))
(defun c-font-lock-enclosing-decls (limit)
@@ -1996,85 +2014,6 @@ on level 2 only and so aren't combined with `c-complex-decl-matchers'."
2 font-lock-type-face)
`(,(concat "\\<\\(" re "\\)\\>")
1 'font-lock-type-face)))
-
- ;; Fontify types preceded by `c-type-prefix-kwds' (e.g. "struct").
- ,@(when (c-lang-const c-type-prefix-kwds)
- `((,(byte-compile
- `(lambda (limit)
- (c-fontify-types-and-refs
- ((c-promote-possible-types t)
- ;; The font-lock package in Emacs is known to clobber
- ;; `parse-sexp-lookup-properties' (when it exists).
- (parse-sexp-lookup-properties
- (cc-eval-when-compile
- (boundp 'parse-sexp-lookup-properties))))
- (save-restriction
- ;; Narrow to avoid going past the limit in
- ;; `c-forward-type'.
- (narrow-to-region (point) limit)
- (while (re-search-forward
- ,(concat "\\<\\("
- (c-make-keywords-re nil
- (c-lang-const c-type-prefix-kwds))
- "\\)\\>")
- limit t)
- (unless (c-skip-comments-and-strings limit)
- (c-forward-syntactic-ws)
- ;; Handle prefix declaration specifiers.
- (while
- (or
- (when (or (looking-at c-prefix-spec-kwds-re)
- (and (c-major-mode-is 'java-mode)
- (looking-at "@[A-Za-z0-9]+")))
- (c-forward-keyword-clause 1)
- t)
- (when (and c-opt-cpp-prefix
- (looking-at
- c-noise-macro-with-parens-name-re))
- (c-forward-noise-clause)
- t)))
- ,(if (c-major-mode-is 'c++-mode)
- `(when (and (c-forward-type)
- (eq (char-after) ?=))
- ;; In C++ we additionally check for a "class
- ;; X = Y" construct which is used in
- ;; templates, to fontify Y as a type.
- (forward-char)
- (c-forward-syntactic-ws)
- (c-forward-type))
- `(c-forward-type))
- )))))))))
-
- ;; Fontify symbols after closing braces as declaration
- ;; identifiers under the assumption that they are part of
- ;; declarations like "class Foo { ... } foo;". It's too
- ;; expensive to check this accurately by skipping past the
- ;; brace block, so we use the heuristic that it's such a
- ;; declaration if the first identifier is on the same line as
- ;; the closing brace. `c-font-lock-declarations' will later
- ;; override it if it turns out to be an new declaration, but
- ;; it will be wrong if it's an expression (see the test
- ;; decls-8.cc).
-;; ,@(when (c-lang-const c-opt-block-decls-with-vars-key)
-;; `((,(c-make-font-lock-search-function
-;; (concat "}"
-;; (c-lang-const c-single-line-syntactic-ws)
-;; "\\(" ; 1 + c-single-line-syntactic-ws-depth
-;; (c-lang-const c-type-decl-prefix-key)
-;; "\\|"
-;; (c-lang-const c-symbol-key)
-;; "\\)")
-;; `((c-font-lock-declarators limit t nil) ; That nil says use `font-lock-variable-name-face';
-;; ; t would mean `font-lock-function-name-face'.
-;; (progn
-;; (c-put-char-property (match-beginning 0) 'c-type
-;; 'c-decl-id-start)
-;; ; 'c-decl-type-start)
-;; (goto-char (match-beginning
-;; ,(1+ (c-lang-const
-;; c-single-line-syntactic-ws-depth)))))
-;; (goto-char (match-end 0)))))))
-
;; Fontify the type in C++ "new" expressions.
,@(when (c-major-mode-is 'c++-mode)
;; This pattern is a probably a "(MATCHER . ANCHORED-HIGHLIGHTER)"
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 7a285f93d34..9495d602e09 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1891,6 +1891,17 @@ the type of that expression."
t (c-make-keywords-re t (c-lang-const c-typeof-kwds)))
(c-lang-defvar c-typeof-key (c-lang-const c-typeof-key))
+(c-lang-defconst c-template-typename-kwds
+ "Keywords which, within a template declaration, can introduce a
+declaration with a type as a default value. This is used only in
+C++ Mode, e.g. \"<typename X = Y>\"."
+ t nil
+ c++ '("class" "typename"))
+
+(c-lang-defconst c-template-typename-key
+ t (c-make-keywords-re t (c-lang-const c-template-typename-kwds)))
+(c-lang-defvar c-template-typename-key (c-lang-const c-template-typename-key))
+
(c-lang-defconst c-type-prefix-kwds
"Keywords where the following name - if any - is a type name, and
where the keyword together with the symbol works as a type in
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index abd77bd973d..e956637572c 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -2314,7 +2314,7 @@ to nil."
nil t)))) ; Only one
(progn
(forward-word-strictly 1)
- (setq name (file-name-base)
+ (setq name (file-name-base (buffer-file-name))
p (point))
(insert " NAME\n\n" name
" - \n\n=head1 SYNOPSIS\n\n\n\n"
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el
index 9231e118907..92a42b1cb94 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -5240,7 +5240,7 @@ Can run from `after-save-hook'."
class
(cond ((not (boundp 'idlwave-scanning-lib))
(list 'buffer (buffer-file-name)))
-; ((string= (downcase (file-name-base))
+; ((string= (downcase (file-name-base (buffer-file-name))
; (downcase name))
; (list 'lib))
; (t (cons 'lib (file-name-nondirectory (buffer-file-name))))
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 4f79703833d..6a17d382b0a 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -68,6 +68,11 @@ string bytes that can be copied is 3/4 of this value."
:version "25.1"
:type 'integer)
+(defcustom xterm-set-window-title t
+ "Whether Emacs should set window titles to an Emacs frame in an XTerm."
+ :version "27.1"
+ :type 'boolean)
+
(defconst xterm-paste-ending-sequence "\e[201~"
"Characters send by the terminal to end a bracketed paste.")
@@ -802,6 +807,8 @@ We run the first FUNCTION whose STRING matches the input events."
(when (memq 'setSelection xterm-extra-capabilities)
(xterm--init-activate-set-selection)))
+ (when xterm-set-window-title
+ (xterm--init-frame-title))
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
@@ -828,6 +835,34 @@ We run the first FUNCTION whose STRING matches the input events."
"Terminal initialization for `gui-set-selection'."
(set-terminal-parameter nil 'xterm--set-selection t))
+(defun xterm--init-frame-title ()
+ "Terminal initialization for XTerm frame titles."
+ (xterm-set-window-title)
+ (add-hook 'after-make-frame-functions 'xterm-set-window-title-flag)
+ (add-hook 'window-configuration-change-hook 'xterm-unset-window-title-flag)
+ (add-hook 'post-command-hook 'xterm-set-window-title)
+ (add-hook 'minibuffer-exit-hook 'xterm-set-window-title))
+
+(defvar xterm-window-title-flag nil
+ "Whether a new frame has been created, calling for a title update.")
+
+(defun xterm-set-window-title-flag (_frame)
+ "Set `xterm-window-title-flag'.
+See `xterm--init-frame-title'"
+ (setq xterm-window-title-flag t))
+
+(defun xterm-unset-window-title-flag ()
+ (when xterm-window-title-flag
+ (setq xterm-window-title-flag nil)
+ (xterm-set-window-title)))
+
+(defun xterm-set-window-title (&optional terminal)
+ "Set the window title of the Xterm TERMINAL.
+The title is constructed from `frame-title-format'."
+ (send-string-to-terminal
+ (format "\e]2;%s\a" (format-mode-line frame-title-format))
+ terminal))
+
(defun xterm--selection-char (type)
(pcase type
('PRIMARY "p")
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index c2c5ca3de06..f9f23201b43 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -314,7 +314,7 @@ also applies `reftex-translate-to-ascii-function' to the string."
(save-match-data
(cond
((equal letter "f")
- (file-name-base))
+ (file-name-base (buffer-file-name)))
((equal letter "F")
(let ((masterdir (file-name-directory (reftex-TeX-master-file)))
(file (file-name-sans-extension (buffer-file-name))))
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 13f761e69e7..d3150403927 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -42,6 +42,9 @@
;; beginning-op Function to call to skip to the beginning of a "thing".
;; end-op Function to call to skip to the end of a "thing".
;;
+;; For simple things, defined as sequences of specific kinds of characters,
+;; use macro define-thing-chars.
+;;
;; Reliance on existing operators means that many `things' can be accessed
;; without further code: eg.
;; (thing-at-point 'line)
@@ -237,21 +240,28 @@ The bounds of THING are determined by `bounds-of-thing-at-point'."
(put 'defun 'end-op 'end-of-defun)
(put 'defun 'forward-op 'end-of-defun)
+;; Things defined by sets of characters
+
+(defmacro define-thing-chars (thing chars)
+ "Define THING as a sequence of CHARS.
+E.g.:
+\(define-thing-chars twitter-screen-name \"[:alnum:]_\")"
+ `(progn
+ (put ',thing 'end-op
+ (lambda ()
+ (re-search-forward (concat "\\=[" ,chars "]*") nil t)))
+ (put ',thing 'beginning-op
+ (lambda ()
+ (if (re-search-backward (concat "[^" ,chars "]") nil t)
+ (forward-char)
+ (goto-char (point-min)))))))
+
;; Filenames
(defvar thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:"
"Characters allowable in filenames.")
-(put 'filename 'end-op
- (lambda ()
- (re-search-forward (concat "\\=[" thing-at-point-file-name-chars "]*")
- nil t)))
-(put 'filename 'beginning-op
- (lambda ()
- (if (re-search-backward (concat "[^" thing-at-point-file-name-chars "]")
- nil t)
- (forward-char)
- (goto-char (point-min)))))
+(define-thing-chars filename thing-at-point-file-name-chars)
;; URIs