commit 9baad43f9123bee7673134619d01e6e3497eda1d
parent 6ad1b4b2cdf0b9d65a032387489b45c3b07e50fc
Author: dwrz <dwrz@dwrz.net>
Date: Sun, 11 Feb 2024 15:01:09 +0000
Update Emacs init
Diffstat:
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/emacs/init.el b/emacs/init.el
@@ -85,14 +85,27 @@
(switch-to-buffer existing-shell-buffer)
(shell (generate-new-buffer-name shell-buffer-name)))))
+(defun dwrz-vterm-in-current-directory ()
+ "Create or switch to a vterm buffer for the current directory."
+ (interactive)
+ (let* ((default-directory (if (buffer-file-name)
+ (file-name-directory (buffer-file-name))
+ default-directory))
+ (dir-path (expand-file-name default-directory))
+ (vterm-buffer-name (concat "*vterm:" dir-path "*"))
+ (existing-vterm-buffer (get-buffer vterm-buffer-name)))
+ (if existing-vterm-buffer
+ (switch-to-buffer existing-vterm-buffer)
+ (vterm (generate-new-buffer-name vterm-buffer-name)))))
+
(defun dwrz-split-window-two-thirds ()
"Split the current window into two, with a 2/3 and 1/3 vertical split."
(interactive)
(select-window (split-window-vertically
(floor (* 0.666 (window-total-height))))))
-(defun prot-simple-unfill-region-or-paragraph (&optional beg end)
- "Unfill paragraph or, when active, the region. Join all lines in region delimited by BEG and END, if active, while respecting any empty lines (so multiple paragraphs are not joined, just unfilled). If no region is active, operate on the paragraph. The idea is to produce the opposite effect of both `fill-paragraph' and `fill-region'."
+(defun dwrz-unfill-region-or-paragraph (&optional beg end)
+ "Unfill paragraph or active region. If region is active, join all lines delimited by BEG and END, while respecting empty lines as paragraph delimiters. If no region is active, operate on the paragraph."
(interactive "r")
(let ((fill-column most-positive-fixnum))
(if (use-region-p) (fill-region beg end) (fill-paragraph))))
@@ -901,6 +914,7 @@
"c" (cons "copy" #'password-store-copy)
"e" (cons "edit" #'password-store-edit)
"g" (cons "generate" #'password-store-generate)
+ "i" (cons "insert" #'password-store-insert)
"n" (cons "rename" #'password-store-rename)
"r" (cons "remove" #'password-store-remove))
@@ -917,7 +931,7 @@
(defvar-keymap dwrz-region-map
:doc "Prefix keymap for region."
:name "Region"
- "U" #'prot-simple-unfill-region-or-paragraph
+ "U" #'dwrz-unfill-region-or-paragraph
"c" #'rot13-region
"d" #'downcase-region
"f" #'fill-region
@@ -954,7 +968,7 @@
"c" #'vterm-copy-mode
"s" #'dwrz-shell-in-current-directory
"t" #'term
- "v" #'vterm)
+ "v" #'dwrz-vterm-in-current-directory)
(defvar-keymap dwrz-time-map
:doc "Prefix keymap for date and time."