Skip to content

Instantly share code, notes, and snippets.

@et2010
Created March 15, 2017 17:05
Show Gist options
  • Save et2010/d7a547d689f65345a06011a35f5044f1 to your computer and use it in GitHub Desktop.
Save et2010/d7a547d689f65345a06011a35f5044f1 to your computer and use it in GitHub Desktop.
Remove needless whitespace when joining two lines in Chinese
(defun et/fixup-whitespace ()
"Fixup white space between objects around point.
Leave one space or none, according to the context."
(interactive "*")
(save-excursion
(delete-horizontal-space)
(if (or (looking-at "^\\|\\s)")
(save-excursion (forward-char -1)
;; we adapted the regexp here:
(looking-at "\\cc\\|$\\|\\s(\\|\\s'")))
nil
(insert ?\s))))
(defun et/delete-indentation (old-func &rest args)
(cl-letf (((symbol-function 'fixup-whitespace) #'et/fixup-whitespace))
(apply old-func args)))
(advice-add #'delete-indentation :around #'et/delete-indentation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment