stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] [PATCH] Fixed describe-command; help when called with argument r


From: Scott Wolchok
Subject: [STUMP] [PATCH] Fixed describe-command; help when called with argument runs describe-command.
Date: Thu, 8 May 2008 17:27:45 -0400

This makes describe-command actually work instead of describing all
commands as NIL. In addition, if an argument
is supplied to help, that argument will be forwarded to describe
command. This should improve life with stumpish.

I also ran M-x untabify-buffer...why not?

Disclaimer: this is the first thing I've written in Common Lisp.

-Scott Wolchok


---
 user.lisp |   58 ++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/user.lisp b/user.lisp
index c3b3f89..517f0c0 100644
--- a/user.lisp
+++ b/user.lisp
@@ -27,21 +27,21 @@
 (in-package :stumpwm)

 (export '(*root-map*
-         argument-line-end-p
-         argument-pop
-         argument-pop-or-read
-         argument-pop-rest
-         define-stumpwm-command
+          argument-line-end-p
+          argument-pop
+          argument-pop-or-read
+          argument-pop-rest
+          define-stumpwm-command
           defcommand
           defcommand-alias
-         define-stumpwm-type
-         pathname-is-executable-p
-         programs-in-path
-         restarts-menu
-         run-commands
-         run-or-raise
-         run-shell-command
-         set-prefix-key
+          define-stumpwm-type
+          pathname-is-executable-p
+          programs-in-path
+          restarts-menu
+          run-commands
+          run-or-raise
+          run-shell-command
+          set-prefix-key
           window-send-string))

 (defvar *root-map* nil
@@ -556,10 +556,10 @@ each directory seperated by a colon."
    nconc (loop
           for file in (directory (merge-pathnames (make-pathname
:name :wild) dir))
           for namestring = (file-namestring file)
-           when (pathname-is-executable-p file)
-           collect (if full-path
-                       (namestring file)
-                       namestring))))
+            when (pathname-is-executable-p file)
+            collect (if full-path
+                        (namestring file)
+                        namestring))))

 (defstruct path-cache
   programs modification-dates paths)
@@ -582,7 +582,7 @@ each directory seperated by a colon."
 with base. Automagically update the cache."
   (rehash)
   (remove-if-not #'(lambda (p)
-                    (when (<= (length base) (length p))
+                     (when (<= (length base) (length p))
                        (string= base p
                                 :end1 (length base)
                                 :end2 (length base))))
(path-cache-programs *path-cache*)))
@@ -1035,7 +1035,7 @@ string between them."
           finally (return c))))

 (defun call-interactively (command &optional (input ""))
-  "Parse the command's arguments from inputgiven the command's
+  "Parse the command's arguments from input given the command's
 argument specifications then execute it. Returns a string or nil if
 user aborted."
   (declare (type (or string symbol) command)
@@ -1203,9 +1203,19 @@ is using the number, then the windows swap
numbers. Defaults to current group."
                         (mapcar 'print-key-seq (search-kmap kmap-var
*top-map*))
                         (columnize data cols))))

-(defcommand help () ()
+(defun get-command-structure-or-die (command)
+  "Return the command structure for COMMAND; throw an error if not
+found."
+  (or (get-command-structure command)
+      (throw 'error (format nil "Command '~a' not found." command))))
+
+(defcommand help (&optional com) (:rest)
 "Display all the bindings in @var{*root-map*}."
-  (display-keybinding '*root-map*))
+  (if com
+      (describe-command com)
+      (display-keybinding '*root-map*)))

 (defcommand commands () ()
   (let* ((screen (current-screen))
@@ -1946,7 +1956,11 @@ command prints the command bound to the
specified key sequence."
 (defcommand describe-command (com) ((:command "Describe Command: "))
   "Print the online help associated with the specified command."
   (message-no-timeout "Command \"~a\":~%~a" com
-                      (documentation (get-command-structure com) 'function)))
+                      (documentation (progn
+                                       ;is it really a command?
+                                       (get-command-structure-or-die com)
+                                       (get-command-symbol com))
+                                     'function)))

 (defcommand where-is (cmd) ((:rest "Where is command: "))
 "Print the key sequences bound to the specified command."
-- 
1.5.5.1




reply via email to

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