org-dwim-char: cleanup
This commit is contained in:
parent
3950860dd4
commit
bdcc7f5c87
@ -112,8 +112,11 @@ Otherwise, insert two of CHAR and put point between them like `electric-pair'."
|
||||
(let* ((char (or char (string-to-char (this-command-keys))))
|
||||
(word (thing-at-point 'word 'no-properties))
|
||||
;;; test conditions here to be eval'd, separating flow from data
|
||||
;; at beginning of line
|
||||
(beginning-of-line-test '(bolp))
|
||||
;; at beginning of word
|
||||
(beginning-of-word-test '(or (bolp) (eq (char-before (point)) ?\ )))
|
||||
(beginning-of-word-test `(or ,beginning-of-line-test
|
||||
(eq (char-before (point)) ?\ )))
|
||||
;; word is surrounded by `char'
|
||||
(surrounded-by-char-test
|
||||
'(and (eq (char-before (beginning-of-thing 'word)) char)
|
||||
@ -122,12 +125,11 @@ Otherwise, insert two of CHAR and put point between them like `electric-pair'."
|
||||
(double-char-test (eq char (char-after)))
|
||||
;; Weird Org exceptions because org
|
||||
(org-exceptions-test
|
||||
'(or (string-match-p (rx bol (or "#" "*"))
|
||||
(thing-at-point 'line 'no-properties))
|
||||
'(or (and (bolp)
|
||||
(string-match-p (rx bol (or "#" "*"))
|
||||
(thing-at-point 'line 'no-properties)))
|
||||
(org-in-block-p org-protecting-blocks)
|
||||
(org-at-property-p))
|
||||
)
|
||||
)
|
||||
(org-at-property-p))))
|
||||
(cond
|
||||
((eq evil-state 'visual)
|
||||
(let* ((beg (region-beginning))
|
||||
@ -137,19 +139,8 @@ Otherwise, insert two of CHAR and put point between them like `electric-pair'."
|
||||
(if (eval beginning-of-word-test)
|
||||
;; run original function bound to key
|
||||
(let ((charstr (make-string 1 char)))
|
||||
;; (pcase charstr
|
||||
;; ;; TODO: can we not hard-code this?
|
||||
;; ;; MAYBE: with Advice on each below function.
|
||||
;; ;; MAYBE: with `key-binding' fn
|
||||
;; ("_" (call-interactively 'evil-next-line-1-first-non-blank))
|
||||
;; ("/" (call-interactively 'evil-search-forward))
|
||||
;; ("*" (call-interactively 'evil-search-word-forward))
|
||||
;; ("+" (call-interactively 'evil-next-line-first-non-blank))
|
||||
;; ("~" (call-interactively 'evil-invert-char))
|
||||
;; ("=" (call-interactively 'evil-indent)))
|
||||
(call-interactively (alist-get charstr org-vw-old-binds-alist
|
||||
nil nil #'string=))
|
||||
)
|
||||
nil nil #'string=)))
|
||||
(save-excursion
|
||||
(if (eval surrounded-by-char-test)
|
||||
(progn
|
||||
@ -162,6 +153,8 @@ Otherwise, insert two of CHAR and put point between them like `electric-pair'."
|
||||
(insert char))))))
|
||||
((eval double-char-test) (right-char))
|
||||
((eval org-exceptions-test) (insert char))
|
||||
((and (eval beginning-of-line-test) (eq char ?*))
|
||||
(insert char))
|
||||
(t (progn
|
||||
(insert (make-string 2 char))
|
||||
(left-char))))))
|
||||
@ -175,6 +168,9 @@ Store it in the variable `org-vw-old-binds-alist'."
|
||||
(cons key (key-binding key)))
|
||||
mitch/org-dwim-char-chars))))
|
||||
(add-hook 'org-vw-pre-hook #'org-vw-snapshot-bindings nil 'local)
|
||||
|
||||
;; (defun org-vw-backspace)
|
||||
|
||||
;; (setq debug-on-error t)
|
||||
;; --------- LET THY BRAIN NO LONGER TREMBLE, FOR I AM BECOME COMPLETE ---------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user