c/c++: add narf/append-semicolon
This commit is contained in:
parent
96640038a6
commit
a6dc9ebc4a
2 changed files with 21 additions and 0 deletions
|
@ -92,6 +92,23 @@
|
|||
("\\<\\(xstring\\|xchar\\)\\>" . font-lock-type-face)
|
||||
) t))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/append-semicolon ()
|
||||
"Append a semicolon to the end of this (or each selected) non-empty line."
|
||||
(interactive)
|
||||
(let ((beg (if (evil-visual-state-p) evil-visual-beginning (line-beginning-position)))
|
||||
(end (if (evil-visual-state-p) evil-visual-end (line-end-position))))
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(while (< (point) end)
|
||||
(let ((lend (save-excursion (evil-last-non-blank) (point))))
|
||||
(goto-char (1+ lend))
|
||||
(unless (or (eq (char-before) ?\;)
|
||||
(= lend (line-beginning-position)))
|
||||
(insert ";")))
|
||||
(forward-line)))
|
||||
(when (evil-visual-state-p)
|
||||
(evil-normal-state))))
|
||||
|
||||
(provide 'defuns-cc)
|
||||
;;; defuns-cc.el ends here
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
c-tab-always-indent nil
|
||||
c-electric-flag nil)
|
||||
|
||||
(map! (:map c-mode-base-map
|
||||
(:localleader
|
||||
:nv ";" 'narf/append-semicolon)))
|
||||
|
||||
(defun narf/sp-point-is-template-p (id action context)
|
||||
(and (sp-in-code-p id action context)
|
||||
(sp-point-after-word-p id action context)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue