X-Git-Url: https://plomlompom.com/repos/?p=plomvi.el;a=blobdiff_plain;f=plomvi.el;h=bda484d7a1ac73ce63163fff32f1ae6adbe41e0a;hp=8d9b768ed4cf6764410a187549eeb610846b8a7f;hb=HEAD;hpb=83f7c9c98537a242f51367e21ec2a4c85a7ecdf4 diff --git a/plomvi.el b/plomvi.el index 8d9b768..bda484d 100644 --- a/plomvi.el +++ b/plomvi.el @@ -31,15 +31,17 @@ ;;; Instructions: -;; 1. load this script into your init file: (load ...) +;; 1. load this script at the end of your init file: (load ...) -;; 2. to start plomvi by default, put this into your init file: +;; 2. to start plomvi by default, put this right after: ;; (plomvi-global-mode 1) -;; 3. define some otherwise unused keybinding to simulate what would -;; be a jump back from Insert mode to Normal mode in Vim (but is de -;; facto just a plomvi mode activation), such as this: -;; (global-set-key (kbd "") 'plomvi-activate) +;; 3. if you want to use a different keybinding than "C-c C-c C-c" +;; to simulate the jump back from Insert to Normal mode in Vim (de +;; facto just a plomvi mode activation), put a line such as this +;; before the (load ...) line for plomvi (with "C-c" the desired +;; combo): +;; (defvar plomvi-return-combo (kbd "C-c")) @@ -126,14 +128,18 @@ Note that this ignores killed rectangles. (defun plomvi-paste-forward () "Paste last kill rightwards in current line, or (if kill ends in \n) under it. +Doesn't move rightwards before yanking if at end of buffer. + Note that this ignores killed rectangles." (interactive) (if (eq nil (string-match "\n$" (current-kill 0))) (progn - (right-char) + (if (< (point) (point-max)) + (right-char)) (yank)) (end-of-line) - (right-char) + (if (< (point) (point-max)) + (right-char)) (yank) (previous-line))) @@ -153,7 +159,7 @@ Note that this ignores killed rectangles." (defun plomvi-kill-region-lines() "Kill lines of marked region." (interactive) - (plomvi-foo 'kill-region)) + (plomvi-affect-lines-of-region 'kill-region)) (defun plomvi-x() "If rectangle or region marked, kill those; else, kill char after point." @@ -163,8 +169,10 @@ Note that this ignores killed rectangles." (kill-rectangle (region-beginning) (region-end))) ((use-region-p) (kill-region (region-beginning) (region-end))) - (t - (delete-char 1)))) + ((not (= (point) (line-end-position))) + (delete-char 1)) + ((not (= (line-beginning-position) (line-end-position))) + (backward-char) (delete-char 1)))) (defun plomvi-rectangle-mark() "Start marked rectangle, move right one char so a single column is visible." @@ -190,7 +198,7 @@ Note that this ignores killed rectangles." ((and (boundp 'rectangle-mark-mode) (eq t rectangle-mark-mode)) (copy-rectangle-as-kill (region-beginning) (region-end))) ((use-region-p) - (plomvi-foo 'copy-region-as-kill)) + (plomvi-affect-lines-of-region 'copy-region-as-kill)) (t (copy-region-as-kill (line-beginning-position) (+ 1 (line-end-position)))))) @@ -328,3 +336,13 @@ or, on editable buffers, `plomvi-mode-editable'. The latter two's values in plomvi-mode-basic-map)) (add-to-list 'minor-mode-map-alist (cons 'plomvi-mode-editable plomvi-mode-editable-map)) + +(defvar plomvi-callable-mode-map + (let ((map (make-sparse-keymap)) + (return-combo (if (boundp 'plomvi-return-combo) + plomvi-return-combo + (kbd "C-c C-c C-c")))) + (define-key map return-combo 'plomvi-activate) + map)) +(define-minor-mode plomvi-callable-mode "" + :init-value t :keymap "plomvi-callable")