dev: merging from main

This commit is contained in:
Matt Nish-Lapidus 2024-04-05 14:34:14 -04:00
parent c241f11ed1
commit e2cd50cd0c
45 changed files with 232 additions and 296 deletions

View file

@ -487,24 +487,31 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
(defun doom/sudo-find-file (file)
"Open FILE as root."
(interactive "FOpen file as root: ")
(find-file (doom--sudo-file-path (expand-file-name file))))
;; HACK: Disable auto-save in temporary tramp buffers because it could trigger
;; processes that hang silently in the background, making those buffers
;; inoperable for the rest of that session (Tramp caches them).
(let ((auto-save-default nil)
;; REVIEW: use only these when we drop 28 support
(remote-file-name-inhibit-auto-save t)
(remote-file-name-inhibit-auto-save-visited t))
(find-file (doom--sudo-file-path (expand-file-name file)))))
;;;###autoload
(defun doom/sudo-this-file ()
"Open the current file as root."
(interactive)
(find-file
(doom--sudo-file-path
(or buffer-file-name
(when (or (derived-mode-p 'dired-mode)
(derived-mode-p 'wdired-mode))
default-directory)))))
(doom/sudo-find-file
(or (buffer-file-name (buffer-base-buffer))
(when (or (derived-mode-p 'dired-mode)
(derived-mode-p 'wdired-mode))
default-directory)
(user-error "Cannot determine the file path of the current buffer"))))
;;;###autoload
(defun doom/sudo-save-buffer ()
"Save this file as root."
(interactive)
(let ((file (doom--sudo-file-path buffer-file-name)))
(let ((file (doom--sudo-file-path (buffer-file-name (buffer-base-buffer)))))
(if-let (buffer (find-file-noselect file))
(let ((origin (current-buffer)))
(copy-to-buffer buffer (point-min) (point-max))
@ -593,7 +600,12 @@ see), and if nil, defaults to `find-sibling-rules'."
(nconc
results
(mapcar #'expand-file-name
(file-expand-wildcards expansion nil t)))))))))
;; `file-expand-wildcards' has a new REGEXP
;; argument in 29+ that is needed here. This swap
;; makes it behave as if REGEXP == t.
(letf! (defun wildcard-to-regexp (wildcard)
(concat "\\`" wildcard "\\'"))
(file-expand-wildcards expansion nil))))))))))
;; Delete the file itself (in case it matched), and remove
;; duplicates, in case we have several expansions and some match
;; the same subsets of files.