dev: merging from main
This commit is contained in:
commit
e14e30df50
20 changed files with 255 additions and 130 deletions
|
@ -250,8 +250,7 @@ tell you about it. Very annoying. This prevents that."
|
|||
auto-mode-alist
|
||||
'(("/LICENSE\\'" . text-mode)
|
||||
("\\.log\\'" . text-mode)
|
||||
("rc\\'" . conf-mode)
|
||||
("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode)))
|
||||
("rc\\'" . conf-mode)))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -143,14 +143,8 @@
|
|||
(setq selection-coding-system 'utf-8))
|
||||
|
||||
|
||||
;;; Support for more file extensions
|
||||
;; Add support for additional file extensions.
|
||||
(dolist (entry '(("/\\.doom\\(?:rc\\|project\\|module\\|profile\\)\\'" . emacs-lisp-mode)
|
||||
("/LICENSE\\'" . text-mode)
|
||||
("\\.log\\'" . text-mode)
|
||||
("rc\\'" . conf-mode)
|
||||
("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode)))
|
||||
(push entry auto-mode-alist))
|
||||
;;; Support for Doom-specific file extensions
|
||||
(add-to-list 'auto-mode-alist '("/\\.doom\\(?:rc\\|project\\|module\\|profile\\)\\'" . emacs-lisp-mode))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -484,17 +484,50 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
|
|||
file))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/sudo-find-file (file)
|
||||
"Open FILE as root."
|
||||
(interactive "FOpen file as root: ")
|
||||
;; 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)))))
|
||||
(defun doom/sudo-find-file (file &optional arg)
|
||||
"Open FILE as root.
|
||||
|
||||
This will prompt you to save the current buffer, unless prefix ARG is given, in
|
||||
which case it will save it without prompting."
|
||||
(interactive
|
||||
(list (read-file-name "Open file as root: ")
|
||||
current-prefix-arg))
|
||||
;; HACK: Teach `save-place' to treat the new "remote" buffer as if it were
|
||||
;; visiting the same local file (because it is), and preserve the cursor
|
||||
;; position as usual.
|
||||
(letf! ((defun remote-local-name (path)
|
||||
(if path (or (file-remote-p path 'localname) path)))
|
||||
(defmacro with-local-name (&rest body)
|
||||
`(when save-place-mode
|
||||
(let ((buffer-file-name (remote-local-name buffer-file-name))
|
||||
(default-directory (remote-local-name default-directory)))
|
||||
,@body))))
|
||||
(let ((window-start (window-start))
|
||||
(buffer (current-buffer)))
|
||||
(when (and buffer-file-name (file-equal-p buffer-file-name file))
|
||||
(when (buffer-modified-p)
|
||||
(save-some-buffers arg (lambda () (eq (current-buffer) buffer))))
|
||||
(with-local-name (save-place-to-alist)))
|
||||
(prog1
|
||||
;; 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)
|
||||
;; Prevent redundant work
|
||||
save-place-mode)
|
||||
(find-file (doom--sudo-file-path (expand-file-name file))))
|
||||
;; Record of the cursor's old position if it isn't at BOB (indicating
|
||||
;; this buffer was already open), in case the user wishes to go to it.
|
||||
(unless (bobp)
|
||||
(doom-set-jump-h)
|
||||
;; save-place-find-file-hook requires point be a BOB to do its thang.
|
||||
(goto-char (point-min)))
|
||||
(with-local-name (save-place-find-file-hook))
|
||||
(set-window-start nil window-start)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/sudo-this-file ()
|
||||
|
@ -528,9 +561,17 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
|
|||
(defun doom/remove-recent-file (file)
|
||||
"Remove FILE from your recently-opened-files list."
|
||||
(interactive
|
||||
(list (completing-read "Remove recent file: " recentf-list
|
||||
(list (completing-read "Remove recent file: "
|
||||
(lambda (string predicate action)
|
||||
(if (eq action 'metadata)
|
||||
'(metadata
|
||||
(display-sort-function . identity)
|
||||
(cycle-sort-function . identity)
|
||||
(category . file))
|
||||
(complete-with-action
|
||||
action recentf-list string predicate)))
|
||||
nil t)))
|
||||
(setq recentf-list (delete file recentf-list))
|
||||
(setq recentf-list (delete (recentf-expand-file-name file) recentf-list))
|
||||
(recentf-save-list)
|
||||
(message "Removed %S from `recentf-list'" (abbreviate-file-name file)))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue