Skip to content

Instantly share code, notes, and snippets.

@moyashi
Created July 6, 2010 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyashi/465285 to your computer and use it in GitHub Desktop.
Save moyashi/465285 to your computer and use it in GitHub Desktop.
(defun my-toggle-bool()
"Invert bool value at point."
(interactive)
(skip-chars-backward "YESNOTRUEFALSEtruefalsetnil")
(or (looking-at "\\(TRUE\\|FALSE\\|true\\|false\\|YES\\|NO\\|t\\|nil\\)")
(error "No bool at point"))
(cond
((equal (match-string 0) "TRUE")
(replace-match "FALSE"))
((equal (match-string 0) "FALSE")
(replace-match "TRUE"))
((equal (match-string 0) "true")
(replace-match "false"))
((equal (match-string 0) "false")
(replace-match "true"))
((equal (match-string 0) "YES")
(replace-match "NO"))
((equal (match-string 0) "NO")
(replace-match "YES"))
((equal (match-string 0) "nil")
(replace-match "t"))
((equal (match-string 0) "t")
(replace-match "nil"))
))
(global-set-key "\C-c!" 'my-toggle-bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment