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

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

[elpa] externals/frog-menu dcca698 33/43: Allow passing no actions


From: Clemens Radermacher
Subject: [elpa] externals/frog-menu dcca698 33/43: Allow passing no actions
Date: Sun, 24 Mar 2019 05:14:48 -0400 (EDT)

branch: externals/frog-menu
commit dcca69811d67281d23817fba51a495a870162735
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Allow passing no actions
---
 frog-menu.el | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/frog-menu.el b/frog-menu.el
index 4bce299..2fdc4f8 100644
--- a/frog-menu.el
+++ b/frog-menu.el
@@ -280,7 +280,8 @@ ACTIONS."
      (point))
    '(face frog-menu-prompt-face))
   (insert "\n")
-  (insert formatted-actions)
+  (when formatted-actions
+    (insert formatted-actions))
   (when formatted-strings
       ;; padding for avy char
     (goto-char (point-min))
@@ -302,27 +303,27 @@ ACTIONS."
    (funcall frog-menu-grid-width-function)))
 
 (defun frog-menu-action-format (actions)
-  (with-temp-buffer
-    (let ((header-pos (point)))
-      (dolist (action actions)
-        (add-text-properties
-         (point)
-         (progn
-           (insert (car action)
-                   "_"
-                   (replace-regexp-in-string " " "_"
-                                             (cadr action))
-                   " ")
-           (point))
-         '(face frog-menu-actions-face)))
-      (insert "\n")
-      (let ((fill-column (1+ (funcall frog-menu-grid-width-function))))
-        (fill-region header-pos (point))
-        (align-regexp header-pos (point) "\\(\\s-*\\) " 1 1 nil)
-        (while (re-search-backward "_" header-pos t)
-          (replace-match " "))))
-    (goto-char (point-min))
-    (buffer-string)))
+  (when actions
+    (with-temp-buffer
+      (let ((header-pos (point)))
+        (dolist (action actions)
+          (add-text-properties
+           (point)
+           (progn
+             (insert (car action)
+                     "_"
+                     (replace-regexp-in-string " " "_"
+                                               (cadr action))
+                     " ")
+             (point))
+           '(face frog-menu-actions-face)))
+        (insert "\n")
+        (let ((fill-column (1+ (funcall frog-menu-grid-width-function))))
+          (fill-region header-pos (point))
+          (align-regexp header-pos (point) "\\(\\s-*\\) " 1 1 nil)
+          (while (re-search-backward "_" header-pos t)
+            (replace-match " "))))
+      (buffer-string))))
 
 (defun frog-menu--grid-format (strings cols &optional width)
   "Return grid string built with STRINGS.



reply via email to

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