From cc87261421ebcb1dc87c8380347e9260a69c998d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 3 Oct 2023 22:41:30 +1100 Subject: [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 --- emacs/.emacs.d/lisp/my/my-editing.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'emacs/.emacs.d/lisp/my/my-editing.el') 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 -- cgit v1.2.3