Merge from origin/emacs-28

23112f89f9 ; Improve documentation of 'file-name-with-extension'
4be938169d Release the desktop lock in 'kill-emacs-hook'
4ea1f6c7f8 ; * doc/lispref/tips.texi (Documentation Tips): Fix typos....

# Conflicts:
#	doc/lispref/tips.texi
This commit is contained in:
Stefan Kangas 2022-07-28 14:56:24 +02:00
commit 7b55a3dab6
3 changed files with 18 additions and 10 deletions

View file

@ -712,7 +712,7 @@ two exceptions: write @code{t} and @code{nil} without surrounding
punctuation. For example:
@example
CODE can be `lambda', nil, or t.
CODE can be `lambda', nil, or t.
@end example
Note that when Emacs displays these doc strings, Emacs will usually
@ -868,7 +868,7 @@ find an alternate phrasing that conveys the meaning.
@item
Try to avoid using abbreviations such as ``e.g.'' (for ``for
example''), ``i.e.'' (for ``that is''), ``no.'' (for ``number''),
``c.f.'' (for ``in contrast to'') and ``w.r.t.'' (for ``with respect
``cf.'' (for ``in contrast to'') and ``w.r.t.'' (for ``with respect
to'') as much as possible. It is almost always clearer and easier to
read the expanded version.@footnote{We do use these occasionally, but
try not to overdo it.}

View file

@ -791,7 +791,10 @@ if different)."
;; ----------------------------------------------------------------------------
(unless noninteractive
(add-hook 'kill-emacs-query-functions #'desktop-kill))
(add-hook 'kill-emacs-query-functions #'desktop-kill)
;; Certain things should be done even if
;; `kill-emacs-query-functions' are not called.
(add-hook 'kill-emacs-hook #'desktop--on-kill))
(defun desktop-kill ()
"If `desktop-save-mode' is non-nil, do what `desktop-save' says to do.
@ -818,12 +821,15 @@ is nil, ask the user where to save the desktop."
(file-error
(unless (yes-or-no-p "Error while saving the desktop. Ignore? ")
(signal (car err) (cdr err))))))
(desktop--on-kill)
t)
(defun desktop--on-kill ()
;; If we own it, we don't anymore.
(when (eq (emacs-pid) (desktop-owner))
;; Allow exiting Emacs even if we can't delete the desktop file.
(ignore-error 'file-error
(desktop-release-lock)))
t)
(desktop-release-lock))))
;; ----------------------------------------------------------------------------
(defun desktop-list* (&rest args)

View file

@ -5119,14 +5119,16 @@ extension, the value is \"\"."
"")))))
(defun file-name-with-extension (filename extension)
"Set the EXTENSION of a FILENAME.
"Return FILENAME modified to have the specified EXTENSION.
The extension (in a file name) is the part that begins with the last \".\".
This function removes any existing extension from FILENAME, and then
appends EXTENSION to it.
Trims a leading dot from the EXTENSION so that either \"foo\" or
\".foo\" can be given.
EXTENSION may include the leading dot; if it doesn't, this function
will provide it.
Errors if the FILENAME or EXTENSION are empty, or if the given
FILENAME has the format of a directory.
It is an error if FILENAME or EXTENSION is empty, or if FILENAME
is in the form of a directory name according to `directory-name-p'.
See also `file-name-sans-extension'."
(let ((extn (string-trim-left extension "[.]")))