Created
July 6, 2010 11:51
-
-
Save moyashi/465285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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