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

CP customization hacks



Here are some hacks that customize the Command Processor in
three simple ways:  
  1.  Keeping it from creating a completer table for a given argument
      type (if you feel it takes more time than it's worth).
  2.  Turning off :confirm on the Show Directory command so that
      "Show Directory<return>" is a valid command; normally it complains that
      "you must supply a value for the Pathname argument".
  3.  Changing the default value for an argument from one constant to another.

You probably don't want to copy this stuff verbatim into your init-file,
but you can use it as an example to work from.

This code works in Release 6.  Naturally, there's a good chance that it won't
work in future releases without some changes.

					--Kanef

;;; -*- Package: System-Internals; -*-

;;;(1) Speed up Set Package etc. by suppressing the completion feature.
;;;    Due to Andy Witkin.
(remprop :package :cp-completer)
;;;(setf (cp-type-completer :package) nil) should work but doesn't.

;;; A useful function for (2) and (3):

(defun command-argument (command-name argument-key
			 &optional (key-function #'arg-keyword))
  ;;Example:  (command-argument 'com-load-file :file-spec 'arg-keyword)
  ;; and      (command-argument 'com-load-file :pathname 'arg-type)
  ;; and      (command-argument 'com-load-file "File Spec" 'arg-name)
  ;; all return the same thing.
  ;;Example: (setf (arg-confirm-p (command-argument 'com-load-file
  ;;						    :file-spec 'arg-keyword))
  ;;		   nil)
  ;;		makes "Load File<return>" work.
 (cl:find argument-key
	  (cmd-args (get command-name 'command))
	  :key key-function
	  :test #'cl:equalp))

;;; (2) Turning off :confirm

(loop for command in '(com-show-directory
			com-show-file
			com-load-file
			com-compile-file)
      do (setf (arg-confirm-p (command-argument command :pathname 'arg-type))
	       nil))

;;; (3) Changing a default.
;;;	WARNING:  It isn't always as simple as this.  See the definition of
;;;		  the ARG structure at the top of sys:cp;define-command.lisp
;;;		  and note how the default-type field is used.
;;;     Here I'm changing "Show Users" with no argument to mean
;;;     "Show Users Bookworm" instead of "Show Users All".
(setf (si:arg-default (command-argument 'com-show-users :host 'arg-type)) 
      (list (net:find-object-named :host "Bookworm")))	;"Show Users<cr>"
(setf (si:arg-mentioned-default (command-argument 'com-show-users :host 'arg-type)) 
      (list (net:find-object-named :host "Bookworm")))	;"Show Users<sp><sp><cr>"