emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master fddedd2 24/24: Merge commit '1380f8c1a51f31514125a08f632d0


From: Oleh Krehel
Subject: [elpa] master fddedd2 24/24: Merge commit '1380f8c1a51f31514125a08f632d017cdfb8e26e' from hydra
Date: Fri, 01 May 2015 14:27:25 +0000

branch: master
commit fddedd20a99a84be82c14bc76c63c56d2fb9b570
Merge: d183352 1380f8c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Merge commit '1380f8c1a51f31514125a08f632d017cdfb8e26e' from hydra
    
    Conflicts:
        packages/hydra/hydra.el
        packages/hydra/lv.el
---
 packages/hydra/.dir-locals.el    |    6 ++++
 packages/hydra/hydra-examples.el |    1 +
 packages/hydra/hydra-test.el     |   15 +++++++++-
 packages/hydra/hydra.el          |   61 ++++++++++++++++++++++++-------------
 packages/hydra/lv.el             |   58 +++++++++++++++++++++++++++++-------
 5 files changed, 107 insertions(+), 34 deletions(-)

diff --git a/packages/hydra/.dir-locals.el b/packages/hydra/.dir-locals.el
new file mode 100644
index 0000000..eb08357
--- /dev/null
+++ b/packages/hydra/.dir-locals.el
@@ -0,0 +1,6 @@
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((emacs-lisp-mode
+  (bug-reference-url-format . "https://github.com/abo-abo/hydra/issues/%s";)
+  (indent-tabs-mode . nil)))
diff --git a/packages/hydra/hydra-examples.el b/packages/hydra/hydra-examples.el
index 67aaffd..c202997 100644
--- a/packages/hydra/hydra-examples.el
+++ b/packages/hydra/hydra-examples.el
@@ -224,6 +224,7 @@ _~_: modified      ^ ^                ^ ^                ^^
 
 ;;** Example 9: s-expressions in the docstring
 ;; You can inline s-expresssions into the docstring like this:
+(defvar dired-mode-map)
 (when (bound-and-true-p hydra-examples-verbatim)
   (require 'dired)
   (defhydra hydra-marked-items (dired-mode-map "")
diff --git a/packages/hydra/hydra-test.el b/packages/hydra/hydra-test.el
index 9385ee6..ab41e82 100644
--- a/packages/hydra/hydra-test.el
+++ b/packages/hydra/hydra-test.el
@@ -1041,11 +1041,24 @@ _f_ auto-fill-mode:    %`auto-fill-function
            nil
            '(nil nil :hint nil)
            "\n_j_,_k_"
-           '(("j" nil) ("k" nil)))
+           '(("j" nil nil :exit t) ("k" nil nil :exit t)))
           '(concat (format "%s,%s"
                     #("j" 0 1 (face hydra-face-blue))
                     #("k" 0 1 (face hydra-face-blue))) ""))))
 
+(ert-deftest hydra-format-5 ()
+  (should
+   (equal (hydra--format
+           nil nil "\n_-_: mark          _u_: unmark\n"
+           '(("-" Buffer-menu-mark)
+             ("u" Buffer-menu-unmark)))
+          '(concat
+           (format
+            "%s: mark          %s: unmark\n"
+            #("-" 0 1 (face hydra-face-red))
+            #("u" 0 1 (face hydra-face-red)))
+            ""))))
+
 (ert-deftest hydra-format-with-sexp-1 ()
   (should (equal
            (let ((hydra-fontify-head-function
diff --git a/packages/hydra/hydra.el b/packages/hydra/hydra.el
index 8bc4341..f50cbf8 100644
--- a/packages/hydra/hydra.el
+++ b/packages/hydra/hydra.el
@@ -5,7 +5,7 @@
 ;; Author: Oleh Krehel <address@hidden>
 ;; Maintainer: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/hydra
-;; Version: 0.13.1
+;; Version: 0.13.2
 ;; Keywords: bindings
 ;; Package-Requires: ((cl-lib "0.5"))
 
@@ -88,6 +88,10 @@
 (defvar hydra-curr-foreign-keys nil
   "The current :foreign-keys behavior.")
 
+(defvar hydra-deactivate nil
+  "If a Hydra head sets this to t, exit the Hydra even if the
+  head wasn't designated for exiting.")
+
 (defun hydra-set-transient-map (keymap on-exit &optional foreign-keys)
   "Set KEYMAP to the highest priority.
 
@@ -99,11 +103,13 @@ that isn't in KEYMAP is called:
 nil: deactivate KEYMAP and run the command.
 run: keep KEYMAP and run the command.
 warn: keep KEYMAP and issue a warning instead of running the command."
-  (setq hydra-curr-map keymap)
-  (setq hydra-curr-on-exit on-exit)
-  (setq hydra-curr-foreign-keys foreign-keys)
-  (add-hook 'pre-command-hook 'hydra--clearfun)
-  (internal-push-keymap keymap 'overriding-terminal-local-map))
+  (if hydra-deactivate
+      (hydra-keyboard-quit)
+    (setq hydra-curr-map keymap)
+    (setq hydra-curr-on-exit on-exit)
+    (setq hydra-curr-foreign-keys foreign-keys)
+    (add-hook 'pre-command-hook 'hydra--clearfun)
+    (internal-push-keymap keymap 'overriding-terminal-local-map)))
 
 (defun hydra--clearfun ()
   "Disable the current Hydra unless `this-command' is a head."
@@ -128,6 +134,7 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
 
 (defun hydra-disable ()
   "Disable the current Hydra."
+  (setq hydra-deactivate nil)
   (remove-hook 'pre-command-hook 'hydra--clearfun)
   (dolist (frame (frame-list))
     (with-selected-frame frame
@@ -191,6 +198,11 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
   "Default `format'-style specifier for _a_  syntax in docstrings.
 When nil, you can specify your own at each location like this: _ 5a_.")
 
+(make-obsolete-variable
+ 'hydra-key-format-spec
+ "Since the docstrings are aligned by hand anyway, this isn't very useful."
+ "0.13.1")
+
 (defface hydra-face-red
     '((t (:foreground "#FF0000" :bold t)))
   "Red Hydra heads don't exit the Hydra.
@@ -214,7 +226,7 @@ Exitable only through a blue head.")
 
 (defface hydra-face-teal
     '((t (:foreground "#367588" :bold t)))
-  "Teal body has blue heads an warns on intercepting non-heads.
+  "Teal body has blue heads and warns on intercepting non-heads.
 Exitable only through a blue head.")
 
 ;;* Fontification
@@ -380,18 +392,21 @@ Return DEFAULT if PROP is not in H."
 (defvar hydra-message-timer (timer-create)
   "Timer for the hint.")
 
+(defvar hydra--work-around-dedicated t
+  "When non-nil, assume there's no bug in `pop-to-buffer'
+  selecting a dedicated window.")
+
 (defun hydra-keyboard-quit ()
   "Quitting function similar to `keyboard-quit'."
   (interactive)
   (hydra-disable)
   (cancel-timer hydra-timeout-timer)
   (cancel-timer hydra-message-timer)
-  (if hydra-lv
-      (when (window-live-p lv-wnd)
-        (let ((buf (window-buffer lv-wnd)))
-          (delete-window lv-wnd)
-          (kill-buffer buf)))
-    (message ""))
+  (unless (and hydra--ignore
+               (null hydra--work-around-dedicated))
+   (if hydra-lv
+       (lv-delete-window)
+     (message "")))
   nil)
 
 (defun hydra--hint (body heads)
@@ -437,7 +452,7 @@ HEAD's binding is returned as a string with a colored face."
               (run 'pink)
               (t 'red)))))
     (when (and (null (cadr head))
-               (not (eq head-color 'blue)))
+               (not head-exit))
       (hydra--complain "nil cmd can only be blue"))
     (propertize (car head) 'face
                 (cl-case head-color
@@ -473,7 +488,7 @@ The expressions can be auto-expanded according to NAME."
         offset)
     (while (setq start
                  (string-match
-                  "\\(?:%\\( 
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\( 
?-?[0-9]*\\)\\([[:alnum:]-~.,;:/|?<>={}*+#]+\\)_\\)"
+                  "\\(?:%\\( 
?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:_\\( 
?-?[0-9]*?\\)\\([-[:alnum:] ~.,;:/|?<>={}*+#]+?\\)_\\)"
                   docstring start))
       (cond ((eq ?_ (aref (match-string 0 docstring) 0))
              (let* ((key (match-string 4 docstring))
@@ -515,8 +530,9 @@ The expressions can be auto-expanded according to NAME."
 
 (defun hydra--complain (format-string &rest args)
   "Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil."
-  (when hydra-verbose
-    (apply #'warn format-string args)))
+  (if hydra-verbose
+      (apply #'error format-string args)
+    (apply #'message format-string args)))
 
 (defun hydra--doc (body-key body-name heads)
   "Generate a part of Hydra docstring.
@@ -700,9 +716,8 @@ JOINER is a function similar to `concat'."
            strs))
    "\n"))
 
-(defcustom hydra-cell-format "% -20s %% -8`%s"
-  "The default format for docstring cells."
-  :type 'string)
+(defvar hydra-cell-format "% -20s %% -8`%s"
+  "The default format for docstring cells.")
 
 (defun hydra--table (names rows cols &optional cell-formats)
   "Format a `format'-style table from variables in NAMES.
@@ -957,7 +972,7 @@ result of `defhydra'."
                (or body-body-pre body-pre) body-before-exit
                '(setq prefix-arg current-prefix-arg)))))
     (error
-     (message "Error in defhydra %S: %s" name (cdr err))
+     (hydra--complain "Error in defhydra %S: %s" name (cdr err))
      nil)))
 
 (defmacro defhydradio (name _body &rest heads)
@@ -1022,8 +1037,10 @@ DOC defaults to TOGGLE-NAME split and capitalized."
                  i)))))
 
 ;; Local Variables:
-;; outline-regexp: ";;\\*+"
+;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|("
+;; indent-tabs-mode: nil
 ;; End:
 
 (provide 'hydra)
+
 ;;; hydra.el ends here
diff --git a/packages/hydra/lv.el b/packages/hydra/lv.el
index f51d185..e4425a2 100644
--- a/packages/hydra/lv.el
+++ b/packages/hydra/lv.el
@@ -33,6 +33,24 @@
 
 ;;; Code:
 
+(defgroup lv nil
+  "The other echo area."
+  :group 'minibuffer
+  :group 'hydra)
+
+(defcustom lv-use-separator nil
+  "Whether to draw a line between the LV window and the Echo Area."
+  :group 'lv
+  :type 'boolean)
+
+(defface lv-separator
+  '((((class color) (background light)) :background "grey80")
+    (((class color) (background  dark)) :background "grey30"))
+  "Face used to draw line between the lv window and the echo area.
+This is only used if option `lv-use-separator' is non-nil.
+Only the background color is significant."
+  :group 'lv)
+
 (defvar lv-wnd nil
   "Holds the current LV window.")
 
@@ -50,6 +68,7 @@
             (switch-to-buffer buf)
           (switch-to-buffer "*LV*")
           (set-window-hscroll lv-wnd 0)
+          (setq window-size-fixed t)
           (setq mode-line-format nil)
           (setq cursor-type nil)
           (set-window-dedicated-p lv-wnd t)
@@ -58,22 +77,39 @@
 
 (defvar golden-ratio-mode)
 
+(defvar lv-force-update nil
+  "When non-nil, `lv-message' will refresh even for the same string.")
+
 (defun lv-message (format-string &rest args)
   "Set LV window contents to (`format' FORMAT-STRING ARGS)."
-  (let* ((ori (selected-window))
-         (str (apply #'format format-string args))
+  (let* ((str (apply #'format format-string args))
          (n-lines (cl-count ?\n str))
          deactivate-mark
          golden-ratio-mode)
-    (select-window (lv-window))
-    (unless (string= (buffer-string) str)
-      (delete-region (point-min) (point-max))
-      (insert str)
-      (setq-local window-min-height n-lines)
-      (setq truncate-lines (> n-lines 1))
-      (fit-window-to-buffer nil nil 1))
-    (goto-char (point-min))
-    (select-window ori)))
+    (with-selected-window (lv-window)
+      (unless (and (string= (buffer-string) str)
+                   (null lv-force-update))
+        (delete-region (point-min) (point-max))
+        (insert str)
+        (when (and (window-system) lv-use-separator)
+          (unless (looking-back "\n" nil)
+            (insert "\n"))
+          (insert
+           (propertize "__" 'face 'lv-separator 'display '(space :height (1)))
+           (propertize "\n" 'face 'lv-separator 'line-height t)))
+        (setq-local window-min-height n-lines)
+        (setq truncate-lines (> n-lines 1))
+        (let ((window-resize-pixelwise t)
+              (window-size-fixed nil))
+          (fit-window-to-buffer nil nil 1)))
+      (goto-char (point-min)))))
+
+(defun lv-delete-window ()
+  "Delete LV window and kill its buffer."
+  (when (window-live-p lv-wnd)
+    (let ((buf (window-buffer lv-wnd)))
+      (delete-window lv-wnd)
+      (kill-buffer buf))))
 
 (provide 'lv)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]