Last active
September 19, 2021 00:53
-
-
Save daniel-koudouna/39f03845914e34acde4d4c6a27c5176a to your computer and use it in GitHub Desktop.
Revisions
-
daniel-koudouna revised this gist
Feb 7, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,18 +25,18 @@ (let ((relative-loc (my:compare-with-end-of-word))) (cond ((my:is-end-of-line) (end-of-line) (call-interactively func)) ((eq 0 relative-loc) (evil-forward-char) (call-interactively func)) ((and (> 0 relative-loc) (not (my:point-is-space))) (evil-forward-word-end) (if (my:is-end-of-line) (end-of-line) (evil-forward-char)) (call-interactively func)) (t (call-interactively func))))) ;; Example usage (defun my:reftex-citation () -
daniel-koudouna created this gist
Feb 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ (defun my:is-end-of-line () "Compare point with end of line." (let* ((pos (current-column)) (end-pos (save-excursion (evil-end-of-line) (current-column)))) (eq pos end-pos))) (defun my:compare-with-end-of-word () "Compare point with end of word." (let* ((pos (current-column)) (end-pos (save-excursion (evil-backward-word-begin) (evil-forward-word-end) (current-column)))) (- pos end-pos))) (defun my:point-is-space () "Check if point is whitespace." (char-equal ?\s (char-after))) (defun my:insert-after (func) "Run FUNC after the end of word, ignoring whitespace." (interactive) (let ((relative-loc (my:compare-with-end-of-word))) (cond ((my:is-end-of-line) (end-of-line) (funcall func)) ((eq 0 relative-loc) (evil-forward-char) (funcall func)) ((and (> 0 relative-loc) (not (my:point-is-space))) (evil-forward-word-end) (if (my:is-end-of-line) (end-of-line) (evil-forward-char)) (funcall func)) (t (funcall func))))) ;; Example usage (defun my:reftex-citation () "Custom reftex to ensure citations appear at the end of words." (interactive) (my:insert-after 'reftex-citation))