Skip to content

Instantly share code, notes, and snippets.

@edwin-bluekite
Created February 1, 2013 13:57
Show Gist options
  • Save edwin-bluekite/4691447 to your computer and use it in GitHub Desktop.
Save edwin-bluekite/4691447 to your computer and use it in GitHub Desktop.
Emacs Add semicolon at the end of the line
(defun semicolon ()
"Add semicolon at the end of the line and return to current position"
(interactive)
(setq current (point))
(end-of-line)
(if (not (= (preceding-char) 59))
(insert ";")
)
(goto-char current)
)
@myimages
Copy link

myimages commented Jul 9, 2017

a simpler version.

(defun insert-semicolorn ()
"Add semicolon at the end of the line and return to current position"
 (interactive)
 (save-excursion
   (end-of-line)
   (insert ";")))

a better use for that for new comers to emacs is to use it with specific mode like so ( here I am using it with php )

(add-hook 'php-mode-hook
	  (lambda ()
	    (defun insert-semicolorn ()
	      "Add semicolon at the end of the line and return to current position"
	      (interactive)
	      (save-excursion
	      (end-of-line)
	      (insert ";")))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment