aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/my-editing.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-27 19:53:06 +1000
committerYuchen Pei <id@ypei.org>2023-06-27 19:53:06 +1000
commit002c98545eb799b2293ee98459d534339739b032 (patch)
treedd58eeddee67258f02431f7de1533ef85f17d27d /emacs/.emacs.d/lisp/my/my-editing.el
parent4edc5f34347efbc4422947bde97f95918d29229e (diff)
buncha changes
- add gdbinit - attempt to fix tempel in eglot (not working) - add qutebrowser to hmm browser - allow find file to open file:line_no
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-editing.el')
-rw-r--r--emacs/.emacs.d/lisp/my/my-editing.el21
1 files changed, 15 insertions, 6 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el
index 2bbda27..174504d 100644
--- a/emacs/.emacs.d/lisp/my/my-editing.el
+++ b/emacs/.emacs.d/lisp/my/my-editing.el
@@ -110,11 +110,6 @@
(define-key global-map "\M-b" 'backward-word)
(message "M-f is forward-word")))))
-(defun my-kill-line-backward ()
- "Kill from point to the beginning of the line."
- (interactive)
- (kill-line 0))
-
(defun my--duplicate-buffer-substring (beg end &optional indent)
"Duplicate buffer substring between BEG and END positions.
With optional INDENT, run `indent-for-tab-command' after
@@ -362,7 +357,7 @@ Basically move the line up
(defun my-kill-line-backward (&optional arg)
"Calls `my-kill-backward' or `kill-line' with 0 in case of prefix arg."
(interactive "P")
- (if prefix-arg
+ (if arg
(kill-line 0)
(my-kill-backward)))
@@ -402,5 +397,19 @@ With an prefix-arg, copy the file name relative to project root."
(setq show-trailing-whitespace t)
)
+(defun my-find-file-line-number (orig filename &rest args)
+ "Turn files like file.cpp:14 into file.cpp and going to the 14-th line."
+ (save-match-data
+ (let* ((matched (string-match "^\\(.*\\):\\([0-9]+\\):?$" filename))
+ (line-number (and matched
+ (match-string 2 filename)
+ (string-to-number (match-string 2 filename))))
+ (filename (if matched (match-string 1 filename) filename)))
+ (apply orig filename args)
+ (when line-number
+ ;; goto-line is for interactive use
+ (goto-char (point-min))
+ (forward-line (1- line-number))))))
+
(provide 'my-editing)
;;; my-editing.el ends here