Fix whitespacing-eating in org-tables on SPC/DEL

This commit is contained in:
Henrik Lissner 2017-05-19 13:20:50 +02:00
parent 4cd56b46cc
commit 13b2cc9446

View file

@ -103,7 +103,10 @@ afterwards, kill line to column 1."
"Delete back to the previous column of whitespace, or as much whitespace as
possible, or just one char if that's not possible."
(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))
(close-pair-re (sp--get-closing-regexp context))
open-len close-len)
@ -117,6 +120,7 @@ possible, or just one char if that's not possible."
(plist-get (sp-get-thing) :cl)))
(delete-char (- 0 open-len))
(delete-char close-len))
;; Delete up to the nearest tab column IF only whitespace between
;; point and bol.
((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
(if (string-match "\\w*\\(\\s-+\\)$"
(buffer-substring-no-properties (max (point-min) (- p movement)) p))
(delete-char (- 0 (- (match-end 1) (match-beginning 1))))
(call-interactively #'delete-backward-char)))))
(sp-delete-char (- 0 (- (match-end 1) (match-beginning 1))))
(call-interactively delete-backward-char)))))
;; Otherwise do a regular delete
(t (call-interactively #'delete-backward-char)))))
(t (call-interactively delete-backward-char)))))
;;;###autoload
(defun doom/inflate-space-maybe ()
"Checks if point is surrounded by {} [] () delimiters and adds a
space on either side of the point if so."
(interactive)
(let ((command (or (command-remapping #'self-insert-command) #'self-insert-command)))
(if (doom--surrounded-p)
(progn (call-interactively #'self-insert-command)
(save-excursion (call-interactively #'self-insert-command)))
(call-interactively #'self-insert-command)))
(progn (call-interactively command)
(save-excursion (call-interactively command)))
(call-interactively command))))
;;;###autoload
(defun doom/deflate-space-maybe ()