[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master efcffc0 45/72: hydra-examples.el: Add example 9
From: |
Oleh Krehel |
Subject: |
[elpa] master efcffc0 45/72: hydra-examples.el: Add example 9 |
Date: |
Fri, 06 Mar 2015 13:04:16 +0000 |
branch: master
commit efcffc037042d9cfebb5b8a62c396e737615d0eb
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra-examples.el: Add example 9
---
hydra-examples.el | 16 ++++++++++++++++
hydra-test.el | 5 ++---
hydra.el | 2 +-
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/hydra-examples.el b/hydra-examples.el
index fbe77ee..50773b0 100644
--- a/hydra-examples.el
+++ b/hydra-examples.el
@@ -218,6 +218,22 @@ _~_: modified
("q" quit-window "quit" :color blue))
;; Recommended binding:
;; (define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body)
+;;** Example 9: s-expressions in the docstring
+;; You can inline s-expresssions into the docstring like this:
+(when (bound-and-true-p hydra-examples-verbatim)
+ (eval-after-load 'dired
+ (defhydra hydra-marked-items (dired-mode-map "")
+ "
+Number of marked items: %(length (dired-get-marked-files))
+"
+ ("m" dired-mark "mark"))))
+
+;; This results in the following dynamic docstring:
+;;
+;; (format "Number of marked items: %S\n"
+;; (length (dired-get-marked-files)))
+;;
+;; You can use `format'-style width specs, e.g. % 10(length nil).
;;* Windmove helpers
(require 'windmove)
diff --git a/hydra-test.el b/hydra-test.el
index ae3e4c7..2a6b579 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -691,8 +691,7 @@ _f_ auto-fill-mode: %`auto-fill-function
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "quit"))))
- '(concat (format "
-% 3s abbrev-mode: %S
+ '(concat (format "% 3s abbrev-mode: %S
% 3s debug-on-error: %S
% 3s auto-fill-mode: %S
" "{a}" abbrev-mode "{d}" debug-on-error "{f}" auto-fill-function) "[[q]]:
quit"))))
@@ -705,7 +704,7 @@ _f_ auto-fill-mode: %`auto-fill-function
'hydra-toggle nil
"\n_n_ narrow-or-widen-dwim %(progn (message
\"checking\")(buffer-narrowed-p))asdf\n"
'(("n" narrow-to-region nil) ("q" nil "cancel"))))
- '(concat (format "\n% 3s narrow-or-widen-dwim %Sasdf\n"
+ '(concat (format "% 3s narrow-or-widen-dwim %Sasdf\n"
"{n}"
(progn
(message "checking")
diff --git a/hydra.el b/hydra.el
index ca3e23a..a7114ed 100644
--- a/hydra.el
+++ b/hydra.el
@@ -415,7 +415,7 @@ The expressions can be auto-expanded according to NAME."
(substring docstring
(+ (match-end 2) offset -2)))))))
(if (eq ?\n (aref docstring 0))
- `(concat (format ,docstring ,@(nreverse varlist))
+ `(concat (format ,(substring docstring 1) ,@(nreverse varlist))
,rest)
`(format ,(concat docstring ": " rest ".")))))
- [elpa] master c41c932 31/72: README.md: fix tables, (continued)
- [elpa] master c41c932 31/72: README.md: fix tables, Oleh Krehel, 2015/03/06
- [elpa] master 1eebfed 34/72: Allow `format'-style width specifiers in docstring, Oleh Krehel, 2015/03/06
- [elpa] master e962ff1 39/72: hydra.el: remove no :pre, :post restriction for Emacs<24.4, Oleh Krehel, 2015/03/06
- [elpa] master a6c6a55 38/72: Improve compatibility for Emacs <= 24.3, Oleh Krehel, 2015/03/06
- [elpa] master 2c01db0 42/72: hydra.el (hydra--handle-nonhead): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master a71b76e 35/72: Intercept quit signals, Oleh Krehel, 2015/03/06
- [elpa] master ae70e9a 41/72: Fix pink and teal Hydras running :post, Oleh Krehel, 2015/03/06
- [elpa] master 71d70f6 46/72: Add :body-pre switch, Oleh Krehel, 2015/03/06
- [elpa] master cb28124 44/72: Allow sexps in Ruby-style docstrings, Oleh Krehel, 2015/03/06
- [elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master efcffc0 45/72: hydra-examples.el: Add example 9,
Oleh Krehel <=
- [elpa] master ef1f61d 40/72: hydra.el (hydra--handle-nonhead): Fix bug, Oleh Krehel, 2015/03/06
- [elpa] master 2eddb83 43/72: hydra-test.el (hydra-format): New test, Oleh Krehel, 2015/03/06
- [elpa] master 5242aad 48/72: Fix :exit t / :exit nil inheritance issue, Oleh Krehel, 2015/03/06
- [elpa] master 0f733d8 37/72: Add an option to fontify heads in a custom way, Oleh Krehel, 2015/03/06
- [elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings, Oleh Krehel, 2015/03/06
- [elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom, Oleh Krehel, 2015/03/06
- [elpa] master 0d9c95e 47/72: Update README.md, Oleh Krehel, 2015/03/06
- [elpa] master 3c06695 56/72: Amend the key regex in docstring to include <>, Oleh Krehel, 2015/03/06
- [elpa] master e567bd6 59/72: lv.el (lv-window): set-window-parameter 'no-other-window, Oleh Krehel, 2015/03/06
- [elpa] master eb1e0fc 58/72: Don't bind nil heads in outside keymaps, Oleh Krehel, 2015/03/06