[Linedit-cvs] CVS update: src/command-functions.lisp src/editor.lisp src/generic-backend.lisp src/utility-macros.lisp

Nikodemus Siivola nsiivola at common-lisp.net
Sat Sep 27 09:18:56 UTC 2003


Date: Sat Sep 27 05:18:56 2003
Author: nsiivola

Index: src/command-functions.lisp
diff -u src/command-functions.lisp:1.1.2.2 src/command-functions.lisp:1.1.2.3
--- src/command-functions.lisp:1.1.2.2	Fri Sep 26 06:58:30 2003
+++ src/command-functions.lisp	Sat Sep 27 05:18:55 2003
@@ -105,23 +105,23 @@
 ;;; KILLING & YANKING
 
 (defun %yank (editor)
-  (let ((yank (buffer-peek (editor-killring editor))))
-    (if yank
-	(with-editor-point-and-string ((point string) editor)
-	  (setf (editor-string editor)
-		(concat (subseq string 0 point) yank (subseq string point))
-		(editor-point editor) (+ point (length yank))))
-	(beep editor))))
+  (aif (buffer-peek (editor-killring editor))
+       (with-editor-point-and-string ((point string) editor)
+	 (setf (editor-string editor)
+	       (concat (subseq string 0 (editor-yank editor))
+		       it
+		       (subseq string point))
+	       (editor-point editor) (+ (editor-yank editor) (length it))))
+	(beep editor)))
 
 (defun yank (chord editor)
   (declare (ignore chord))
-  (setf (editor-yank editor) (editor-point editor))
+  (remember-yank editor)
   (%yank editor))
 
 (defun yank-cycle (chord editor)
   (declare (ignore chord))
-  (setf (editor-yank editor) (editor-last-yank editor))
-  (if (editor-yank editor)
+  (if (try-yank editor)
       (progn
 	 (buffer-cycle (editor-killring editor))
 	 (%yank editor))
@@ -159,7 +159,7 @@
 	(copy-region t editor)
 	(setf (editor-string editor)
 	      (concat (subseq string 0 start) (subseq string end))
-	      (editot-point editor) start)))))
+	      (editor-point editor) start)))))
 
 (defun set-mark (chord editor)
   (declare (ignore chord))


Index: src/editor.lisp
diff -u src/editor.lisp:1.1.2.2 src/editor.lisp:1.1.2.3
--- src/editor.lisp:1.1.2.2	Fri Sep 26 06:58:30 2003
+++ src/editor.lisp	Sat Sep 27 05:18:55 2003
@@ -42,6 +42,12 @@
    (insert :reader editor-insert-mode
 	   :initform t
 	   :initarg :insert-mode)
+   (mark :accessor editor-mark
+	 :initform nil)
+   (yank :accessor editor-yank
+	 :initform nil)
+   (last-yank :accessor editor-last-yank
+	      :initform nil)
    (prompt :reader editor-prompt
 	   :initform ""
 	   :initarg :prompt)))
@@ -54,6 +60,7 @@
       (insert (copy line) pool))))
 
 (defun next-chord (editor)
+  (forget-yank editor)
   (let* ((chord (read-chord (editor-backend editor)))
 	 (command (gethash chord (editor-commands editor)
 			   (if (characterp chord)
@@ -148,6 +155,16 @@
 (defun editor-complete (editor)
   (funcall (editor-completer editor) (editor-word editor)))
 
+(defun remember-yank (editor)
+  (setf (editor-yank editor) (editor-point editor)))
+
+(defun forget-yank (editor)
+  (shiftf (editor-last-yank editor) (editor-yank editor) nil))
+
+(defun try-yank (editor)
+  (setf (editor-yank editor) (editor-last-yank editor))
+  (editor-yank editor))
+
 (defun editor-replace-word (editor word)
   (with-editor-point-and-string ((point string) editor)
     (let ((start (editor-word-start editor))
@@ -159,3 +176,4 @@
 (defmethod print-in-columns ((editor editor) list &key width)
   (print-in-columns (editor-backend editor) list :width width)
   (refresh editor))
+


Index: src/generic-backend.lisp
diff -u src/generic-backend.lisp:1.1.2.2 src/generic-backend.lisp:1.1.2.3
--- src/generic-backend.lisp:1.1.2.2	Fri Sep 26 06:58:30 2003
+++ src/generic-backend.lisp	Sat Sep 27 05:18:55 2003
@@ -57,8 +57,9 @@
 	  , at forms)
      (unless *backend-suspended*
        (awhen (backend-cached-action ,backend)
-	  (setf (backend-cached-action ,backend) nil)
-	  (funcall it)))))
+	  (locally (declare (function it))
+	    (setf (backend-cached-action ,backend) nil)
+	    (funcall it))))))
 
 (defmethod display :around ((backend backend) prompt line)
   (if *backend-suspended*


Index: src/utility-macros.lisp
diff -u src/utility-macros.lisp:1.1.2.1 src/utility-macros.lisp:1.1.2.2
--- src/utility-macros.lisp:1.1.2.1	Tue Sep 23 00:47:21 2003
+++ src/utility-macros.lisp	Sat Sep 27 05:18:55 2003
@@ -21,6 +21,12 @@
 
 (in-package :linedit)
 
+(defmacro aif (condition consequent &optional alternative)
+  `(let ((it ,condition))
+     (if it
+	 ,consequent
+	 ,alternative)))
+
 (defmacro acase (form &rest cases)
   `(let ((it ,form))
      (case it
@@ -35,9 +41,8 @@
      , at body))
 
 (defmacro awhen (condition &body body)
-  `(let ((it ,condition))
-     (when it
-       , at body)))
+  `(aif ,condition
+	(progn , at body)))
 
 (defmacro do-internal-symbols ((var package) &body forms)
   (with-unique-names (state)

Update of /project/linedit/cvsroot/src
In directory common-lisp.net:/tmp/cvs-serv7679

Modified Files:
      Tag: rewrite-1
	command-functions.lisp editor.lisp generic-backend.lisp 
	utility-macros.lisp 
Log Message:
Fixed yanking.






More information about the linedit-cvs mailing list