[climacs-devel] Point - buffer or pane? (plus syntax resetting)

John Q Splittist splittist at yahoo.com
Wed May 4 07:38:51 UTC 2005


Currently point is kept in the climacs-pane object. While this means one 
can have multiple panes on the same buffer with different points, it 
does mean that switching buffers in the same pane loses the point 
information, so point is always reset.

Below are some changes to pane.lisp that move point to the 
climacs-buffer object. This has the effect of _not_ resetting point when 
doing a com-switch-to-buffer. Of course, when you com-split-window-*, 
there is only one point for each of the panes, so the cursors follow one 
another. Interesting redisplay features can be observed.

Presumably the right thing to do is have one point (and mark, and 
perhaps other things - isearch, query-replace?) per buffer per pane. On 
a com-split-window the new pane could be given some kind of proxy 
climacs-buffer pointing to the original, but with its own state.

Or maybe I'm barking up the wrong tree.

Anyway, consider this a quick fix for the annoyance of losing one's 
place in a file when switching buffers.

Also, by commenting out lines in com-switch-to-buffer (in gui.lisp) as 
follows, a syntax reset can be avoided on c-x b as well:

(define-named-command com-switch-to-buffer ()
   (let ((buffer (accept 'buffer
			:prompt "Switch to buffer"))
	(pane (current-window)))
     (setf (buffer pane) buffer)
;    (setf (syntax buffer) (make-instance
;			   'basic-syntax :buffer (buffer (point pane))))
;    (beginning-of-buffer (point pane))
     (full-redisplay pane)))

JQS

--- pane.lisp.~1.24.~	Wed Apr  6 06:31:53 2005
+++ pane.lisp	Wed May  4 07:46:08 2005
@@ -193,7 +193,10 @@
  (defclass extended-binseq2-buffer (binseq2-buffer p-undo-mixin 
abbrev-mixin) ()
    (:documentation "Extensions accessible via marks."))

-(defclass climacs-buffer (delegating-buffer filename-mixin name-mixin)
+(defclass point-mixin ()
+  ((point :initform nil :initarg :point :accessor point)))
+
+(defclass climacs-buffer (delegating-buffer filename-mixin name-mixin 
point-mixin)
    ((needs-saving :initform nil :accessor needs-saving)
     (syntax :accessor syntax)
     (indent-tabs-mode :initarg indent-tabs-mode :initform t
@@ -210,7 +213,6 @@

  (defclass climacs-pane (application-pane)
    ((buffer :initform (make-instance 'climacs-buffer) :accessor buffer)
-   (point :initform nil :initarg :point :reader point)
     (mark :initform nil :initarg :mark :accessor mark)
     (top :reader top)
     (bot :reader bot)
@@ -231,6 +233,12 @@
  		      (insert* cache 0 nil)
  		      cache))))

+(defmethod point ((pane climacs-pane))
+  (point (buffer pane)))
+
+(defmethod (setf point) (mark (pane climacs-pane))
+  (setf (point (buffer pane)) mark))
+
  (defmethod tab-width ((pane climacs-pane))
    (tab-width (stream-default-view pane)))

@@ -239,9 +247,9 @@

  (defmethod initialize-instance :after ((pane climacs-pane) &rest args)
    (declare (ignore args))
-  (with-slots (buffer point mark) pane
-     (when (null point)
-       (setf point (clone-mark (low-mark buffer) :right)))
+  (with-slots (buffer mark) pane
+     (when (null (point pane))
+       (setf (point pane) (clone-mark (low-mark buffer) :right)))
       (when (null mark)
         (setf mark (clone-mark (low-mark buffer) :right))))
    (with-slots (buffer top bot scan) pane
@@ -255,11 +263,12 @@
  	     tab-width (* 8 space-width)))))

  (defmethod (setf buffer) :after (buffer (pane climacs-pane))
-  (with-slots (point mark top bot) pane
-       (setf point (clone-mark (low-mark buffer) :right)
-	     mark (clone-mark (low-mark buffer) :right)
-	     top (clone-mark (low-mark buffer) :left)
-	     bot (clone-mark (high-mark buffer) :right))))
+  (with-slots (mark top bot) pane
+    (unless (point pane)
+      (setf (point pane) (clone-mark (low-mark buffer) :right)))
+    (setf mark (clone-mark (low-mark buffer) :right)
+          top (clone-mark (low-mark buffer) :left)
+          bot (clone-mark (high-mark buffer) :right))))

  (define-presentation-type url ()
    :inherit-from 'string)



More information about the climacs-devel mailing list