[climacs-devel] a patch for climacs (mainly regarding COMPLETABLY-PATHNAME) + a gimmick

Max-Gerd Retzlaff m.retzlaff at gmx.net
Wed Aug 31 02:05:56 UTC 2005


Hello,


 The COMPLETABLE-PATHNAME class

This patch mainly removes the class COMPLETABLE-PATHNAME. There is
nothing special about those pathnames that make them completable. They
are just ordinary pathnames (no offence meant). The only difference to
the normal PATHNAME presentation-type is that there are different
ACCEPT and PRESENT methods for it. (This ACCEPT offers completion over
pathnames, and the PRESENT just calls NAMESTRING on the pathname
before presenting it.)

This is better done by specialization on the VIEW keyword and not
by subclassing PATHNAME. This patch changes Climacs to the former
behaviour.

The VIEW subclass on which the methods specialize with this patch is
CLIMACS-TEXTUAL-VIEW. It has already bean created in pane.lisp but was
not yet used anywhere, therefore I just took it. Is it intended for
something else that prohibits the use in this context? To be able to
use it as a specializer in lambda-lists the variable
climacs-pane:+climacs-textual-view+ has been added, it hold an
instance of the class climacs-pane:climacs-textual-view, just as there
are such variables for the standard view classes (see clim spec 23.6).
Both symbols, #:climacs-textual-view and #:+climacs-textual-view+, of
the package CLIMACS-PANE are exported.

+climacs-textual-view+ is also the :default-view for the class
CLIMACS-GUI::CLIMACS-MINIBUFFER-PANE now, so that the aforementioned
ACCEPT and PRESENT methods for pathnames are used in the minibuffer.
(See at the beginning of gui.lisp.) Is there a special reason why the
:DEFAULT-VIEW for the class CLIMACS-PANE:CLIMACS-PANE is not specified
in the same way, but in the :AFTER method of (initialize-instance (pane
climacs-pane)) via the line:

  (setf (stream-default-view pane) (make-instance 'climacs-textual-view))

I propose to change this as well, but this patch doesn't do this yet.

As the :DEFAULT-VIEW of the minibuffer is now changed, all the calls to
   (accept 'completable-pathname :prompt "..")
are now substituted by just
   (accept 'pathname :prompt "..")
without the need for explicit specification by use of the :VIEW
keyword. All these calls are changed, even the one in
slidemacs-gui.lisp.


We should think about to moving this ACCEPT method for pathnames (or
something like it) into the McCLIM code, and making it the default
ACCEPT method for the TEXTUAL-VIEW class. Completion for pathnames is
always nice, isn't it?


While we are at PRESENTing pathames: It would nice if in the
climacs-info-pane (aka modeline) the name of the buffer would be
presented via something like:

(let ((name (name buffer))
      (filepath (filepath buffer)))
  (if filepath
      (with-output-as-presentation (pane filepath 'pathname)
        (princ name pane))
      (princ name pane)))

and not printed in this huge FORMAT of CLIMACS-GUI::DISPLAY-INFO.



 The function CLIMACS-GUI:CLIMACS

I added the keywords NEW-PROCESS and PROCESS-NAME to the lambda-list
and the correspondent construct. You can now do
   (climacs-gui:climacs :new-process t)
Just as it is possible with Clouseau and the Climacs-Listener.

I think this construct should be provided by McCLIM as an exported
macro. I've seen it in the Listener, Clouseau, the Beagle-Backend (in
Glimpse), and I use it in my own CLIM applications... Well, this
belogs to mcclim-devel.

CLIMACS-GUI:CLIMACS is also exported now. Why wasn't it before?



Okay, that's all. Only one question left: Why is the variable in the
DEFINE-APPLICATION-FRAME form that holds the minibuffer-pane called
"int"? What is the meaning of "int"?  I don't get it.

Bye,
Max


PS: A gimmick for your entertainment, as you've come to the end
    of this rather long mail:

Substitute +climacs-textual-view+ in the slot :default-view for the
class definition of CLIMACS-MINIBUFFER-PANE by +gadget-view+, apply
   http://bl0rg.net/~mgr/flux/CLIM-Listener.patch
to the Clim-Listener in your McCLIM source tree (cd mcclim/Apps/Listener/;
patch -p 1 < CLIM-Listener.patch) (will soon be commited), download and load
   http://bl0rg.net/~mgr/flux/file-selector.lisp
(version 1.1!), and fire up FIND FILE in Climacs. You'll get:

   http://bl0rg.net/~mgr/flux/File-Selector-as-Find-File-of-Climacs.png

(I prefer the none gadget-view for the minibuffer, though..)

-- 
Max-Gerd Retzlaff <m.retzlaff at gmx.net>

For your amusement:
The secret of healthy hitchhiking is to eat junk food.
-------------- next part --------------
Index: gui.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/gui.lisp,v
retrieving revision 1.183
diff -a -u -r1.183 gui.lisp
--- gui.lisp	25 Aug 2005 08:43:55 -0000	1.183
+++ gui.lisp	31 Aug 2005 00:30:12 -0000
@@ -47,7 +47,8 @@
 (defclass climacs-minibuffer-pane (minibuffer-pane)
   ()
   (:default-initargs
-      :height 20 :max-height 20 :min-height 20))
+      :height 20 :max-height 20 :min-height 20
+      :default-view +climacs-textual-view+))
 
 (defparameter *with-scrollbars* t
   "If T, classic look and feel. If NIL, stripped-down look (:")
@@ -98,11 +99,15 @@
     (loop for buffer in buffers
 	  do (clear-modify buffer))))
 
-(defun climacs (&key (width 900) (height 400))
+(defun climacs (&key new-process (process-name "Climacs")
+                (width 900) (height 400))
   "Starts up a climacs session"
-  (let ((frame (make-application-frame
-		'climacs :width width :height height)))
-    (run-frame-top-level frame)))
+  (let ((frame (make-application-frame 'climacs :width width :height height)))
+    (flet ((run ()
+	     (run-frame-top-level frame)))
+      (if new-process
+	  (clim-sys:make-process #'run :name process-name)
+	  (run)))))
 
 (defun display-info (frame pane)
   (declare (ignore frame))
@@ -556,10 +561,6 @@
       (possibly-fill-line)
       (setf (offset point) (offset point-backup)))))
 
-(eval-when (:compile-toplevel :load-toplevel)
-  (define-presentation-type completable-pathname ()
-  :inherit-from 'pathname))
-
 (defun filename-completer (so-far mode)
   (flet ((remove-trail (s)
 	   (subseq s 0 (let ((pos (position #\/ s :from-end t)))
@@ -628,15 +629,12 @@
 		       collect (list (subseq (namestring name) length nil)
 				     name))))))))
 
-(define-presentation-method present (object (type completable-pathname)
-					    stream (view textual-view)
-					    &key acceptably for-context-type)
-  (declare (ignore acceptably for-context-type))
+(define-presentation-method present (object (type pathname)
+                                            stream (view climacs-textual-view) &key)
   (princ (namestring object) stream))
 
-(define-presentation-method accept
-    ((type completable-pathname) stream (view textual-view) &key (default nil defaultp)
-     (default-type type))
+(define-presentation-method accept ((type pathname) stream (view climacs-textual-view)
+                                    &key (default nil defaultp) (default-type type))
   (multiple-value-bind (pathname success string)
       (complete-input stream
 		      #'filename-completer
@@ -711,8 +709,7 @@
 		 buffer))))))
 
 (define-named-command com-find-file ()
-  (let* ((filepath (accept 'completable-pathname
-			   :prompt "Find File")))
+  (let* ((filepath (accept 'pathname :prompt "Find File")))
     (find-file filepath)))
 
 (defun find-file-read-only (filepath)
@@ -752,7 +749,7 @@
 		     nil)))))))
 
 (define-named-command com-find-file-read-only ()
-  (let ((filepath (accept 'completable-pathname :Prompt "Find file read only")))
+  (let ((filepath (accept 'pathname :Prompt "Find file read only")))
     (find-file-read-only filepath)))
 
 (define-named-command com-toggle-read-only ()
@@ -765,12 +762,11 @@
 	(needs-saving buffer) t))
 
 (define-named-command com-set-visited-file-name ()
-  (let ((filename (accept 'completable-pathname :prompt "New file name")))
+  (let ((filename (accept 'pathname :prompt "New file name")))
     (set-visited-file-name filename (buffer (current-window)))))
 
 (define-named-command com-insert-file ()
-  (let ((filename (accept 'completable-pathname
-			  :prompt "Insert File"))
+  (let ((filename (accept 'pathname :prompt "Insert File"))
 	(pane (current-window)))
     (when (probe-file filename)
       (setf (mark pane) (clone-mark (point pane) :left))
@@ -818,8 +814,7 @@
 
 (defun save-buffer (buffer)
   (let ((filepath (or (filepath buffer)
-		      (accept 'completable-pathname
-			      :prompt "Save Buffer to File"))))
+		      (accept 'pathname :prompt "Save Buffer to File"))))
     (cond
       ((directory-pathname-p filepath)
        (display-message "~A is a directory." filepath)
@@ -863,8 +858,7 @@
     (call-next-method)))
 
 (define-named-command com-write-buffer ()
-  (let ((filepath (accept 'completable-pathname
-			  :prompt "Write Buffer to File"))
+  (let ((filepath (accept 'pathname :prompt "Write Buffer to File"))
 	(buffer (buffer (current-window))))
     (cond
       ((directory-pathname-p filepath)
@@ -979,8 +973,7 @@
 		(beep))))))
 
 (define-named-command com-load-file ()
-  (let ((filepath (accept 'completable-pathname
-			  :prompt "Load File")))
+  (let ((filepath (accept 'pathname :prompt "Load File")))
     (load-file filepath)))
 
 (define-named-command com-beginning-of-buffer ()
Index: packages.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/packages.lisp,v
retrieving revision 1.79
diff -a -u -r1.79 packages.lisp
--- packages.lisp	19 Aug 2005 09:12:48 -0000	1.79
+++ packages.lisp	31 Aug 2005 00:30:12 -0000
@@ -157,7 +157,8 @@
            #:query-replace-mode
 	   #:mark-visible-p
 	   #:with-undo
-	   #:url))
+	   #:url
+	   #:climacs-textual-view #:+climacs-textual-view+))
 
 (defpackage :climacs-fundamental-syntax
   (:use :clim-lisp :clim :climacs-buffer :climacs-base 
@@ -197,5 +198,5 @@
 (defpackage :climacs-gui
   (:use :clim-lisp :clim :climacs-buffer :climacs-base :climacs-abbrev :climacs-syntax
 	:climacs-kill-ring :climacs-pane :clim-extensions :undo :esa)
-  (:import-from :climacs-lisp-syntax :lisp-string))
-
+  (:import-from :climacs-lisp-syntax :lisp-string)
+  (:export :climacs))
Index: pane.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/pane.lisp,v
retrieving revision 1.31
diff -a -u -r1.31 pane.lisp
--- pane.lisp	28 Aug 2005 13:57:33 -0000	1.31
+++ pane.lisp	31 Aug 2005 00:30:13 -0000
@@ -222,6 +222,8 @@
 (defclass climacs-textual-view (textual-view tabify-mixin)
   ())
 
+(defparameter +climacs-textual-view+ (make-instance 'climacs-textual-view))
+
 (defclass filepath-mixin ()
   ((filepath :initform nil :accessor filepath)))
 
Index: slidemacs-gui.lisp
===================================================================
RCS file: /project/climacs/cvsroot/climacs/slidemacs-gui.lisp,v
retrieving revision 1.16
diff -a -u -r1.16 slidemacs-gui.lisp
--- slidemacs-gui.lisp	22 Jun 2005 18:36:13 -0000	1.16
+++ slidemacs-gui.lisp	31 Aug 2005 00:30:13 -0000
@@ -556,5 +556,5 @@
     (if (not (and (typep pane 'climacs-pane)
                   (typep (syntax (buffer pane)) 'slidemacs-gui-syntax)))
         (beep)
-        (let ((file (accept 'climacs-gui::completable-pathname :prompt "Output to")))
-          (postscript-print-pane pane file)))))
\ No newline at end of file
+        (let ((file (accept 'pathname :prompt "Output to")))
+          (postscript-print-pane pane file)))))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/climacs-devel/attachments/20050831/88dfd079/attachment.sig>


More information about the climacs-devel mailing list