From 3011905d2b2246e0781efd7fd702ec5a5c131cc8 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 15 Oct 2023 06:47:33 +0200 Subject: [PATCH] Make gpolonkai/org-space-key customizable --- .mc-lists.el | 2 +- configuration.org | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.mc-lists.el b/.mc-lists.el index 4ca49d8..4387bf8 100644 --- a/.mc-lists.el +++ b/.mc-lists.el @@ -19,6 +19,7 @@ gpolonkai/duplicate-line gpolonkai/move-to-beginning-of-line gpolonkai/move-to-end-of-line + gpolonkai/org-space-key hungry-delete-backward hungry-delete-forward indent-for-tab-command @@ -35,7 +36,6 @@ org-meta-return org-return org-self-insert-command - org-space-key org-yank overwrite-mode sp-backward-delete-char diff --git a/configuration.org b/configuration.org index 90ab220..ad899a5 100644 --- a/configuration.org +++ b/configuration.org @@ -281,16 +281,22 @@ From [[http://emacs.stackexchange.com/a/31321/507][Emacs SE]]. (org-time-stamp '(16) arg)) #+end_src -*** Insert two spaces after specific characters +*** Insert two spaces after certain marks #+begin_src emacs-lisp -(defun gpolonkai/org-space-key (&optional arg) - "Insert two spaces after a period. +(defcustom gpolonkai/org-dbl-space-punct-marks (list ?. ?! ?? ?…) + "Punctuation marks after which the space key should insert two space characters." + :type '(set character)) -ARG will be passed down verbatim to `self-insert-command'" +(defun gpolonkai/org-space-key (&optional arg) + "Insert two spaces after certain markers. + +ARG will be passed down verbatim to `self-insert-command'." (interactive "p") - (when (looking-back "[.!?…]" nil) + (when (and + (not (org-in-block-p '("src"))) + (looking-back (rx-to-string `(any,@ gpolonkai/org-dbl-space-punct-marks)) nil)) (call-interactively 'self-insert-command arg)) (call-interactively 'self-insert-command arg)) #+end_src