Fix whitespacing-eating in org-tables on SPC/DEL
This commit is contained in:
parent
4cd56b46cc
commit
13b2cc9446
1 changed files with 34 additions and 28 deletions
|
@ -103,7 +103,10 @@ afterwards, kill line to column 1."
|
||||||
"Delete back to the previous column of whitespace, or as much whitespace as
|
"Delete back to the previous column of whitespace, or as much whitespace as
|
||||||
possible, or just one char if that's not possible."
|
possible, or just one char if that's not possible."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((context (sp--get-pair-list-context 'navigate))
|
(let* ((delete-backward-char (if (derived-mode-p 'org-mode)
|
||||||
|
#'org-delete-backward-char
|
||||||
|
#'delete-backward-char))
|
||||||
|
(context (sp--get-pair-list-context 'navigate))
|
||||||
(open-pair-re (sp--get-opening-regexp context))
|
(open-pair-re (sp--get-opening-regexp context))
|
||||||
(close-pair-re (sp--get-closing-regexp context))
|
(close-pair-re (sp--get-closing-regexp context))
|
||||||
open-len close-len)
|
open-len close-len)
|
||||||
|
@ -117,6 +120,7 @@ possible, or just one char if that's not possible."
|
||||||
(plist-get (sp-get-thing) :cl)))
|
(plist-get (sp-get-thing) :cl)))
|
||||||
(delete-char (- 0 open-len))
|
(delete-char (- 0 open-len))
|
||||||
(delete-char close-len))
|
(delete-char close-len))
|
||||||
|
|
||||||
;; Delete up to the nearest tab column IF only whitespace between
|
;; Delete up to the nearest tab column IF only whitespace between
|
||||||
;; point and bol.
|
;; point and bol.
|
||||||
((save-match-data (looking-back "^[\\t ]*" (line-beginning-position)))
|
((save-match-data (looking-back "^[\\t ]*" (line-beginning-position)))
|
||||||
|
@ -127,20 +131,22 @@ possible, or just one char if that's not possible."
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(if (string-match "\\w*\\(\\s-+\\)$"
|
(if (string-match "\\w*\\(\\s-+\\)$"
|
||||||
(buffer-substring-no-properties (max (point-min) (- p movement)) p))
|
(buffer-substring-no-properties (max (point-min) (- p movement)) p))
|
||||||
(delete-char (- 0 (- (match-end 1) (match-beginning 1))))
|
(sp-delete-char (- 0 (- (match-end 1) (match-beginning 1))))
|
||||||
(call-interactively #'delete-backward-char)))))
|
(call-interactively delete-backward-char)))))
|
||||||
|
|
||||||
;; Otherwise do a regular delete
|
;; Otherwise do a regular delete
|
||||||
(t (call-interactively #'delete-backward-char)))))
|
(t (call-interactively delete-backward-char)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/inflate-space-maybe ()
|
(defun doom/inflate-space-maybe ()
|
||||||
"Checks if point is surrounded by {} [] () delimiters and adds a
|
"Checks if point is surrounded by {} [] () delimiters and adds a
|
||||||
space on either side of the point if so."
|
space on either side of the point if so."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(let ((command (or (command-remapping #'self-insert-command) #'self-insert-command)))
|
||||||
(if (doom--surrounded-p)
|
(if (doom--surrounded-p)
|
||||||
(progn (call-interactively #'self-insert-command)
|
(progn (call-interactively command)
|
||||||
(save-excursion (call-interactively #'self-insert-command)))
|
(save-excursion (call-interactively command)))
|
||||||
(call-interactively #'self-insert-command)))
|
(call-interactively command))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/deflate-space-maybe ()
|
(defun doom/deflate-space-maybe ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue