Add highlight-indentation
This commit is contained in:
parent
efd5ff4cb6
commit
54dcb9fd44
3 changed files with 49 additions and 0 deletions
1
Cask
1
Cask
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
;; UI --- core/core-ui.el
|
;; UI --- core/core-ui.el
|
||||||
(depends-on "visual-fill-column")
|
(depends-on "visual-fill-column")
|
||||||
|
(depends-on "highlight-indentation" :git "https://github.com/localredhead/Highlight-Indentation-for-Emacs")
|
||||||
(depends-on "rainbow-delimiters")
|
(depends-on "rainbow-delimiters")
|
||||||
(depends-on "rainbow-mode")
|
(depends-on "rainbow-mode")
|
||||||
(depends-on "nlinum")
|
(depends-on "nlinum")
|
||||||
|
|
|
@ -145,6 +145,24 @@
|
||||||
|
|
||||||
(use-package visual-fill-column :defer t)
|
(use-package visual-fill-column :defer t)
|
||||||
|
|
||||||
|
(use-package highlight-indentation
|
||||||
|
:commands (highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||||
|
:init
|
||||||
|
(add-hook! (web-mode nxml-mode yaml-mode json-mode scss-mode
|
||||||
|
c-mode-common ruby-mode python-mode lua-mode)
|
||||||
|
'highlight-indentation-mode)
|
||||||
|
|
||||||
|
:config
|
||||||
|
;; A long-winded method for ensuring whitespace is maintained (so that
|
||||||
|
;; highlight-indentation-mode can display them consistently)
|
||||||
|
(add-hook! highlight-indentation-mode
|
||||||
|
(if highlight-indentation-mode
|
||||||
|
(progn
|
||||||
|
(narf/add-whitespace)
|
||||||
|
(add-hook 'after-save-hook 'narf/add-whitespace nil t))
|
||||||
|
(remove-hook 'after-save-hook 'narf/add-whitespace t)))
|
||||||
|
(add-hook 'before-save-hook 'delete-trailing-whitespace))
|
||||||
|
|
||||||
(use-package rainbow-delimiters
|
(use-package rainbow-delimiters
|
||||||
:commands rainbow-delimiters-mode
|
:commands rainbow-delimiters-mode
|
||||||
:init
|
:init
|
||||||
|
|
|
@ -46,5 +46,35 @@
|
||||||
(compose-region beg end how 'decompose-region))
|
(compose-region beg end how 'decompose-region))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/add-whitespace (&optional start end)
|
||||||
|
(interactive (progn (barf-if-buffer-read-only)
|
||||||
|
(if (use-region-p)
|
||||||
|
(list (region-beginning) (region-end))
|
||||||
|
(list nil nil))))
|
||||||
|
(save-match-data
|
||||||
|
(save-excursion
|
||||||
|
(let ((end-marker (copy-marker (or end (point-max))))
|
||||||
|
(start (or start (point-min))))
|
||||||
|
(goto-char start)
|
||||||
|
(while (and (re-search-forward "^$" end-marker t) (not (>= (point) end-marker)))
|
||||||
|
(let (line-start line-end)
|
||||||
|
(save-excursion
|
||||||
|
(forward-line -1)
|
||||||
|
(setq line-start (point)
|
||||||
|
line-end (save-excursion (back-to-indentation) (point)))
|
||||||
|
(if (and (= line-start line-end)
|
||||||
|
(/= line-end (line-end-position)))
|
||||||
|
(progn
|
||||||
|
(forward-line 2)
|
||||||
|
(setq line-start (point)
|
||||||
|
line-end (save-excursion (back-to-indentation) (point)))
|
||||||
|
(forward-line -1))
|
||||||
|
(forward-line 1))
|
||||||
|
(insert (make-string (- line-end line-start) 32))))
|
||||||
|
(forward-line 1)))))
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
|
nil)
|
||||||
|
|
||||||
(provide 'defuns-ui)
|
(provide 'defuns-ui)
|
||||||
;;; defuns-ui.el ends here
|
;;; defuns-ui.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue