aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-10-03 22:41:30 +1100
committerYuchen Pei <id@ypei.org>2023-10-03 22:41:30 +1100
commitcc87261421ebcb1dc87c8380347e9260a69c998d (patch)
treea43b80df9342a52654de35b1c3fcc49324da9b60 /emacs
parenta696cbe0f1d96e2ac6a3454d716326f20312a4a8 (diff)
[emacs] [gdb] Some small changes
- my-mark-backward-up-list: like backward-up-list, but also mark the sexp - my-kill-sexp-or-comment: kill the next sexp or comment, replacing kill-sexp - my-mark-sexp-or-comment: mark the next sexp or comment, replacing mark-sexp - my-magit-ignore-other-worktrees: a filter-args advice to add --ignore-other-worktrees to magit-checkout
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init/ycp-editing.el4
-rw-r--r--emacs/.emacs.d/init/ycp-package.el4
-rw-r--r--emacs/.emacs.d/init/ycp-vc.el3
-rw-r--r--emacs/.emacs.d/lisp/my/my-editing.el27
-rw-r--r--emacs/.emacs.d/lisp/my/my-magit.el8
5 files changed, 45 insertions, 1 deletions
diff --git a/emacs/.emacs.d/init/ycp-editing.el b/emacs/.emacs.d/init/ycp-editing.el
index e469097..cdbe09d 100644
--- a/emacs/.emacs.d/init/ycp-editing.el
+++ b/emacs/.emacs.d/init/ycp-editing.el
@@ -42,6 +42,8 @@
;; don't interpret C-m as RET
(define-key input-decode-map [?\C-m] [C-m])
(define-key input-decode-map [?\C-i] [C-i])
+;; fixme: the line below does not work
+;; (define-key input-decode-map [?\C-M-m] [C-M-m])
(setq save-place-file (locate-user-emacs-file "saveplace"))
(my-configure
@@ -89,6 +91,8 @@
"M-SPC" #'cycle-spacing
"M-z" #'zap-up-to-char ; NOT `zap-to-char'
"<C-M-backspace>" #'backward-kill-sexp
+ "C-M-/" #'my-mark-backward-up-list
+ "C-M-k" #'my-kill-sexp-or-comment
)
(electric-pair-mode)
(my-add-hooks #'my-non-special-modes-setup '(text-mode-hook prog-mode-hook))
diff --git a/emacs/.emacs.d/init/ycp-package.el b/emacs/.emacs.d/init/ycp-package.el
index 3662b53..f0af72c 100644
--- a/emacs/.emacs.d/init/ycp-package.el
+++ b/emacs/.emacs.d/init/ycp-package.el
@@ -61,7 +61,9 @@
'((hcel . "elpa-devel")
(luwak . "elpa-devel")))
(add-hook 'package-menu-mode-hook #'hl-line-mode)
-)
+ (my-keybind package-menu-mode-map
+ "g" #'package-refresh-contents)
+ )
(my-package cus-edit
(my-keybind global-map
diff --git a/emacs/.emacs.d/init/ycp-vc.el b/emacs/.emacs.d/init/ycp-vc.el
index 8a3fed5..16261b6 100644
--- a/emacs/.emacs.d/init/ycp-vc.el
+++ b/emacs/.emacs.d/init/ycp-vc.el
@@ -123,6 +123,9 @@
(require 'magit-ediff)
(add-hook 'magit-ediff-quit-hook 'delete-frame)
+
+ (require 'magit-branch)
+ (advice-add 'magit-checkout :filter-args #'my-magit-ignore-other-worktrees)
)
(my-package my-magit
diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el
index f8e405e..b24103f 100644
--- a/emacs/.emacs.d/lisp/my/my-editing.el
+++ b/emacs/.emacs.d/lisp/my/my-editing.el
@@ -481,5 +481,32 @@ With an prefix-arg, copy the file name relative to project root."
(goto-char (point-min))
(forward-line (1- line-number))))))
+(defun my-mark-backward-up-list ()
+ "Mark the sexp containing the current one."
+ (interactive)
+ (backward-up-list)
+ (activate-mark)
+ (set-mark (point))
+ (forward-sexp)
+ (exchange-point-and-mark))
+
+(defun my-kill-sexp-or-comment (&optional n)
+ "Kill the next n sexp. On failure, call `comment-kill' instead."
+ (interactive)
+ (condition-case _
+ (kill-sexp n)
+ (scan-error (comment-kill (or n 1)))))
+
+(defun my-mark-sexp-or-comment ()
+ "Mark the next sexp or comment."
+ (interactive)
+ (condition-case _
+ (mark-sexp)
+ (user-error
+ (set-mark
+ (save-excursion
+ (forward-comment 1)
+ (point))))))
+
(provide 'my-editing)
;;; my-editing.el ends here
diff --git a/emacs/.emacs.d/lisp/my/my-magit.el b/emacs/.emacs.d/lisp/my/my-magit.el
index c6fc0f6..efb3c84 100644
--- a/emacs/.emacs.d/lisp/my/my-magit.el
+++ b/emacs/.emacs.d/lisp/my/my-magit.el
@@ -67,5 +67,13 @@
(replace-regexp-in-string "/build\\>.*" "/src"
default-directory))))
+(defun my-magit-ignore-other-worktrees (rev-and-args)
+ "Add --ignore-other-worktrees to the second element of REV-AND-ARGS.
+
+For use as a :filter-args advice"
+ (pcase-let ((`(,revision ,args) rev-and-args))
+ (list revision
+ (cons "--ignore-other-worktrees" args))))
+
(provide 'my-magit)
;;; my-magit.el ends here