Created
February 18, 2015 16:15
-
-
Save kaushalmodi/51029361a5b3d44f9f34 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
;; Time-stamp: <2015-02-18 11:11:07 kmodi> | |
;; hydra issue #37 | |
;; GNU Emacs 25.0.50.9 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.4) | |
;; of 2015-02-17 | |
;; Global variables (symbols) | |
(setq user-home-directory (getenv "HOME")) | |
(setq user-emacs-directory (concat user-home-directory "/.emacs.d")) | |
(setq my/temp-directory (concat user-emacs-directory "/temp/hydra_issue_37")) | |
(defun prepend-path ( my-path ) | |
(setq load-path (cons (expand-file-name my-path) load-path))) | |
(unless (file-exists-p my/temp-directory) | |
(make-directory my/temp-directory)) | |
;; Download hydra | |
(unless (file-exists-p (concat my/temp-directory "/hydra")) | |
(shell-command (concat | |
"git clone https://github.com/abo-abo/hydra " | |
my/temp-directory | |
"/hydra"))) | |
(prepend-path (concat my/temp-directory "/hydra")) | |
(require 'hydra) | |
(defun endless/comment-line-or-region (n) | |
"Comment or uncomment current line and proceed to the next line. | |
With positive prefix, apply to N lines including current one. | |
With negative prefix, apply to -N lines above. | |
If region is active, apply to active region instead." | |
(interactive "p") | |
(if (use-region-p) | |
(comment-or-uncomment-region | |
(region-beginning) (region-end)) | |
(let ((range | |
(list (line-beginning-position) | |
(goto-char (line-end-position n))))) | |
(comment-or-uncomment-region | |
(apply #'min range) | |
(apply #'max range))) | |
(forward-line 1) | |
(back-to-indentation))) | |
(defhydra hydra-test-issue-37 (:color blue) | |
"test-op-over-region" | |
("u" upcase-region "upcase") ; works | |
("l" downcase-region "downcase") ; works | |
(";" endless/comment-line-or-region "comment") ; DOES NOT WORK | |
("q" nil "cancel" :color blue)) | |
(global-set-key (kbd "M-c") #'hydra-test-issue-37/body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment