dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit aa86516c23ceb25a9f62c208c4c05ddc705b237d
parent 54cc1c71a5d3b7b2c7f60fe5ce6f8d1e80d26ff0
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri, 17 Jun 2022 00:58:06 +0200

emacs: rewrite open-line functions to work like Vim o/O

Diffstat:
Memacs/config.org | 51+++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/emacs/config.org b/emacs/config.org @@ -825,16 +825,14 @@ If you use the ~sender~ option, notifications don't show unless the app is in the background. [[https://github.com/julienXX/terminal-notifier/issues/68][See this Github issue.]] #+begin_src emacs-lisp - (if (and (not (featurep 'dbus)) - (eq system-type 'darwin) - (executable-find "terminal-notifier")) - (setq org-show-notification-handler - (lambda (str) (start-process "terminal-notifier" nil (executable-find "terminal-notifier") - "-title" "Timer done" - "-message" str - "-group" "org.gnu.Emacs" - "-ignoreDnD" - "-activate" "org.gnu.Emacs")))) + ;; on mac without dbus: + ;; (setq org-show-notification-handler + ;; (lambda (str) (start-process "terminal-notifier" nil (executable-find "terminal-notifier") + ;; "-title" "Timer done" + ;; "-message" str + ;; "-group" "org.gnu.Emacs" + ;; "-ignoreDnD" + ;; "-activate" "org.gnu.Emacs")))) #+end_src *** org-caldav @@ -1890,6 +1888,39 @@ Let a period followed by a single space be treated as end of sentence: (with-silent-modifications (remove-text-properties begin end '(read-only t)))) #+end_src +** Open line like in Vim +I prefer to open-line the way o/O works in Vim: + +#+begin_src emacs-lisp + ;; Autoindent open-*-lines + (defvar za/open-line-newline-and-indent t + "Modify the behavior of the open-*-line functions to cause them to autoindent.") + + (defun za/open-line (prefix) + "Open line like `o`/`O` in Vim. Negative prefix for line above, positive for below." + (interactive "p") + (cond ((< prefix 0) + (beginning-of-line) + (open-line (abs prefix))) + (t + (end-of-line) + (open-line prefix) + (forward-line 1))) + (when za/open-line-newline-and-indent + (indent-according-to-mode))) + + (defun za/open-line-keep-point (prefix) + "Open line like `o`/`O` in Vim but don't move point. Negative prefix for line above, positive for below." + (interactive "p") + (save-mark-and-excursion (za/open-line prefix))) +#+end_src + +And keybindings: + +#+begin_src emacs-lisp + (za/global-set-key (kbd "C-o") #'za/open-line) + (za/global-set-key (kbd "C-M-o") #'za/open-line-keep-point) +#+end_src * Markdown Markdown mode settings.