Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; 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
You can’t perform that action at this time.