]> code.delx.au - dotemacs/blobdiff - lisp/my-editing-defuns.el
Improved tide-project-root to understand git and package.json
[dotemacs] / lisp / my-editing-defuns.el
index 8e8ace2e90ae557bf4c324615eca088e1d3a8caa..f05070309467b393b088ecf0c48c4c7fb55d0348 100644 (file)
@@ -1,20 +1,8 @@
 ;;; -*- lexical-binding: t -*-
 
-(defun my/comment-dwim (arg)
-  "Toggles the comment on for the active region if present or the current line otherwise."
-  (interactive "*p")
-  (cond
-   ((and mark-active transient-mark-mode)
-    (let ((start (save-excursion (goto-char (region-beginning)) (line-beginning-position)))
-          (end (save-excursion (goto-char (region-end)) (line-end-position))))
-      (comment-or-uncomment-region start end)))
-   (t
-    (comment-or-uncomment-region (line-beginning-position) (line-end-position arg))
-    (forward-line arg))))
-
 (defun my/copy-line (arg)
   "Copy the current line into the kill ring. With ARG copies that many lines."
-  (interactive "*p")
+  (interactive "p")
   (kill-ring-save (line-beginning-position 1)
                   (line-beginning-position (+ 1 arg)))
   (message "Copied %d lines" arg))
@@ -28,7 +16,7 @@
     (kill-ring-save start end)
     (when at-eof
       (kill-append "\n" t))
-    (save-excursion
+    (save-mark-and-excursion
       (forward-line)
       (dotimes (ignored arg)
         (yank)))
       (kill-line arg))
   (if (not (string-equal major-mode "fundamental-mode"))
       (indent-for-tab-command)))
-
-(defun my/yank (arg)
-  "If the text to be yanked has a newline then move to beginning of line before yanking. Otherwise same as normal `yank'."
-  (interactive "*P")
-  (advice-add 'insert-for-yank :around #'my/yank/advice)
-  (unwind-protect
-      (yank arg)
-    (advice-remove 'insert-for-yank #'my/yank/advice)))
-
-(defun my/yank/advice (original-function string)
-  (if (string-match-p "\n" string)
-      (beginning-of-line))
-  (funcall original-function string))