climacs-cvs
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
August 2005
- 5 participants
- 39 discussions

[climacs-cvs] CVS update: climacs/syntax.lisp climacs/packages.lisp climacs/gui.lisp
by dmurray@common-lisp.net 16 Aug '05
by dmurray@common-lisp.net 16 Aug '05
16 Aug '05
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv5492
Modified Files:
syntax.lisp packages.lisp gui.lisp
Log Message:
Various refactoring to allow non-interactive access to functionality.
Checks to see that buffers aren't written to, or attempted to be
read from, directories. com-load-file now on C-c C-l.
Also some rearrangement of stuff in gui.lisp.
Date: Wed Aug 17 01:10:30 2005
Author: dmurray
Index: climacs/syntax.lisp
diff -u climacs/syntax.lisp:1.56 climacs/syntax.lisp:1.57
--- climacs/syntax.lisp:1.56 Sun Aug 14 14:12:35 2005
+++ climacs/syntax.lisp Wed Aug 17 01:10:29 2005
@@ -216,6 +216,13 @@
(declare (ignore success string))
object))
+(defun syntax-from-name (syntax)
+ (let ((description (find syntax *syntaxes*
+ :key #'syntax-description-name
+ :test #'string-equal)))
+ (when description
+ (find-class (syntax-description-class-name description)))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Basic syntax
Index: climacs/packages.lisp
diff -u climacs/packages.lisp:1.77 climacs/packages.lisp:1.78
--- climacs/packages.lisp:1.77 Tue Aug 16 01:31:22 2005
+++ climacs/packages.lisp Wed Aug 17 01:10:29 2005
@@ -92,6 +92,7 @@
(defpackage :climacs-syntax
(:use :clim-lisp :clim :climacs-buffer :climacs-base :flexichain)
(:export #:syntax #:define-syntax
+ #:syntax-from-name
#:basic-syntax
#:update-syntax #:update-syntax-for-display
#:grammar #:grammar-rule #:add-rule
Index: climacs/gui.lisp
diff -u climacs/gui.lisp:1.177 climacs/gui.lisp:1.178
--- climacs/gui.lisp:1.177 Tue Aug 16 01:31:22 2005
+++ climacs/gui.lisp Wed Aug 17 01:10:29 2005
@@ -189,6 +189,9 @@
(setf (needs-saving (buffer (current-window))) nil))
(define-named-command com-set-fill-column ((column 'integer :prompt "Column Number:"))
+ (set-fill-column column))
+
+(defun set-fill-column (column)
(if (> column 1)
(setf (auto-fill-column (current-window)) column)
(progn (beep) (display-message "Set Fill Column requires an explicit argument."))))
@@ -279,15 +282,17 @@
(delete-range current-point (- (offset item-mark) current-offset))))
(define-named-command com-transpose-objects ()
- (let* ((point (point (current-window))))
- (unless (beginning-of-buffer-p point)
- (when (end-of-line-p point)
- (backward-object point))
- (let ((object (object-after point)))
- (delete-range point)
- (backward-object point)
- (insert-object point object)
- (forward-object point)))))
+ (transpose-objects (point (current-window))))
+
+(defun transpose-objects (mark)
+ (unless (beginning-of-buffer-p mark)
+ (when (end-of-line-p mark)
+ (backward-object mark))
+ (let ((object (object-after mark)))
+ (delete-range mark)
+ (backward-object mark)
+ (insert-object mark object)
+ (forward-object mark))))
(define-named-command com-backward-object ((count 'integer :prompt "Number of Objects"))
(backward-object (point (current-window)) count))
@@ -296,51 +301,55 @@
(forward-object (point (current-window)) count))
(define-named-command com-transpose-words ()
- (let* ((point (point (current-window))))
- (let (bw1 bw2 ew1 ew2)
- (backward-word point)
- (setf bw1 (offset point))
- (forward-word point)
- (setf ew1 (offset point))
- (forward-word point)
- (when (= (offset point) ew1)
- ;; this is emacs' message in the minibuffer
- (error "Don't have two things to transpose"))
- (setf ew2 (offset point))
- (backward-word point)
- (setf bw2 (offset point))
- (let ((w2 (buffer-sequence (buffer point) bw2 ew2))
- (w1 (buffer-sequence (buffer point) bw1 ew1)))
- (delete-word point)
- (insert-sequence point w1)
- (backward-word point)
- (backward-word point)
- (delete-word point)
- (insert-sequence point w2)
- (forward-word point)))))
+ (transpose-words (point (current-window))))
+
+(defun transpose-words (mark)
+ (let (bw1 bw2 ew1 ew2)
+ (backward-word mark)
+ (setf bw1 (offset mark))
+ (forward-word mark)
+ (setf ew1 (offset mark))
+ (forward-word mark)
+ (when (= (offset mark) ew1)
+ ;; this is emacs' message in the minibuffer
+ (error "Don't have two things to transpose"))
+ (setf ew2 (offset mark))
+ (backward-word mark)
+ (setf bw2 (offset mark))
+ (let ((w2 (buffer-sequence (buffer mark) bw2 ew2))
+ (w1 (buffer-sequence (buffer mark) bw1 ew1)))
+ (delete-word mark)
+ (insert-sequence mark w1)
+ (backward-word mark)
+ (backward-word mark)
+ (delete-word mark)
+ (insert-sequence mark w2)
+ (forward-word mark))))
(define-named-command com-transpose-lines ()
- (let ((point (point (current-window))))
- (beginning-of-line point)
- (unless (beginning-of-buffer-p point)
- (previous-line point))
- (let* ((bol (offset point))
- (eol (progn (end-of-line point)
- (offset point)))
- (line (buffer-sequence (buffer point) bol eol)))
- (delete-region bol point)
- ;; Remove newline at end of line as well.
- (unless (end-of-buffer-p point)
- (delete-range point))
- ;; If the current line is at the end of the buffer, we want to
- ;; be able to insert past it, so we need to get an extra line
- ;; at the end.
- (end-of-line point)
- (when (end-of-buffer-p point)
- (insert-object point #\Newline))
- (next-line point 0)
- (insert-sequence point line)
- (insert-object point #\Newline))))
+ (transpose-lines (point (current-window))))
+
+(defun transpose-lines (mark)
+ (beginning-of-line mark)
+ (unless (beginning-of-buffer-p mark)
+ (previous-line mark))
+ (let* ((bol (offset mark))
+ (eol (progn (end-of-line mark)
+ (offset mark)))
+ (line (buffer-sequence (buffer mark) bol eol)))
+ (delete-region bol mark)
+ ;; Remove newline at end of line as well.
+ (unless (end-of-buffer-p mark)
+ (delete-range mark))
+ ;; If the current line is at the end of the buffer, we want to
+ ;; be able to insert past it, so we need to get an extra line
+ ;; at the end.
+ (end-of-line mark)
+ (when (end-of-buffer-p mark)
+ (insert-object mark #\Newline))
+ (next-line mark 0)
+ (insert-sequence mark line)
+ (insert-object mark #\Newline)))
(define-named-command com-previous-line ((numarg 'integer :prompt "How many lines?"))
(let* ((win (current-window))
@@ -365,36 +374,40 @@
(define-named-command com-open-line ((numarg 'integer :prompt "How many lines?"))
(open-line (point (current-window)) numarg))
+(defun kill-line (mark &optional (count 1) (whole-lines-p nil) (concatenate-p nil))
+ (let ((start (offset mark)))
+ (cond ((= 0 count)
+ (beginning-of-line mark))
+ ((< count 0)
+ (loop repeat (- count)
+ until (beginning-of-buffer-p mark)
+ do (beginning-of-line mark)
+ until (beginning-of-buffer-p mark)
+ do (backward-object mark)))
+ ((or whole-lines-p (> count 1))
+ (loop repeat count
+ until (end-of-buffer-p mark)
+ do (end-of-line mark)
+ until (end-of-buffer-p mark)
+ do (forward-object mark)))
+ (t
+ (cond ((end-of-buffer-p mark) nil)
+ ((end-of-line-p mark)(forward-object mark))
+ (t (end-of-line mark)))))
+ (unless (mark= mark start)
+ (if concatenate-p
+ (kill-ring-concatenating-push *kill-ring*
+ (region-to-sequence start mark))
+ (kill-ring-standard-push *kill-ring*
+ (region-to-sequence start mark)))
+ (delete-region start mark))))
+
(define-named-command com-kill-line ((numarg 'integer :prompt "Kill how many lines?")
(numargp 'boolean :prompt "Kill entire lines?"))
(let* ((pane (current-window))
(point (point pane))
- (mark (offset point)))
- (cond ((= 0 numarg)
- (beginning-of-line point))
- ((< numarg 0)
- (loop repeat (- numarg)
- until (beginning-of-buffer-p point)
- do (beginning-of-line point)
- until (beginning-of-buffer-p point)
- do (backward-object point)))
- ((or numargp (> numarg 1))
- (loop repeat numarg
- until (end-of-buffer-p point)
- do (end-of-line point)
- until (end-of-buffer-p point)
- do (forward-object point)))
- (t
- (cond ((end-of-buffer-p point) nil)
- ((end-of-line-p point)(forward-object point))
- (t (end-of-line point)))))
- (unless (mark= point mark)
- (if (eq (previous-command pane) 'com-kill-line)
- (kill-ring-concatenating-push *kill-ring*
- (region-to-sequence mark point))
- (kill-ring-standard-push *kill-ring*
- (region-to-sequence mark point)))
- (delete-region mark point))))
+ (concatenate-p (eq (previous-command pane) 'com-kill-line)))
+ (kill-line point numarg numargp concatenate-p)))
(define-named-command com-forward-word ((count 'integer :prompt "Number of words"))
(if (plusp count)
@@ -407,35 +420,37 @@
(define-named-command com-delete-word ((count 'integer :prompt "Number of words"))
(delete-word (point (current-window)) count))
+(defun kill-word (mark &optional (count 1) (concatenate-p nil))
+ (let ((start (offset mark)))
+ (if (plusp count)
+ (loop repeat count
+ until (end-of-buffer-p mark)
+ do (forward-word mark))
+ (loop repeat (- count)
+ until (beginning-of-buffer-p mark)
+ do (backward-word mark)))
+ (unless (mark= mark start)
+ (if concatenate-p
+ (if (plusp count)
+ (kill-ring-concatenating-push *kill-ring*
+ (region-to-sequence start mark))
+ (kill-ring-reverse-concatenating-push *kill-ring*
+ (region-to-sequence start mark)))
+ (kill-ring-standard-push *kill-ring*
+ (region-to-sequence start mark)))
+ (delete-region start mark))))
+
(define-named-command com-kill-word ((count 'integer :prompt "Number of words"))
(let* ((pane (current-window))
(point (point pane))
- (mark (offset point)))
- (loop repeat count
- until (end-of-buffer-p point)
- do (forward-word point))
- (unless (mark= point mark)
- (if (eq (previous-command pane) 'com-kill-word)
- (kill-ring-concatenating-push *kill-ring*
- (region-to-sequence mark point))
- (kill-ring-standard-push *kill-ring*
- (region-to-sequence mark point)))
- (delete-region mark point))))
+ (concatenate-p (eq (previous-command pane) 'com-kill-word)))
+ (kill-word point count concatenate-p)))
(define-named-command com-backward-kill-word ((count 'integer :prompt "Number of words"))
(let* ((pane (current-window))
(point (point pane))
- (mark (offset point)))
- (loop repeat count
- until (end-of-buffer-p point)
- do (backward-word point))
- (unless (mark= point mark)
- (if (eq (previous-command pane) 'com-backward-kill-word)
- (kill-ring-reverse-concatenating-push *kill-ring*
- (region-to-sequence mark point))
- (kill-ring-standard-push *kill-ring*
- (region-to-sequence mark point)))
- (delete-region mark point))))
+ (concatenate-p (eq (previous-command pane) 'com-backward-kill-word)))
+ (kill-word point (- count) concatenate-p)))
(define-named-command com-mark-word ((count 'integer :prompt "Number of words"))
(let* ((pane (current-window))
@@ -546,18 +561,18 @@
(full-so-far (concatenate 'string directory-prefix so-far))
(pathnames
(loop with length = (length full-so-far)
- and wildcard = (concatenate 'string (remove-trail so-far) "*.*")
- for path in
- #+(or sbcl cmu lispworks) (directory wildcard)
- #+openmcl (directory wildcard :directories t)
- #+allegro (directory wildcard :directories-are-files nil)
- #+cormanlisp (nconc (directory wildcard)
+ and wildcard = (concatenate 'string (remove-trail so-far) "*.*")
+ for path in
+ #+(or sbcl cmu lispworks) (directory wildcard)
+ #+openmcl (directory wildcard :directories t)
+ #+allegro (directory wildcard :directories-are-files nil)
+ #+cormanlisp (nconc (directory wildcard)
(cl::directory-subdirs dirname))
- #-(or sbcl cmu lispworks openmcl allegro cormanlisp)
- (directory wildcard)
- when (let ((mismatch (mismatch (namestring path) full-so-far)))
- (or (null mismatch) (= mismatch length)))
- collect path))
+ #-(or sbcl cmu lispworks openmcl allegro cormanlisp)
+ (directory wildcard)
+ when (let ((mismatch (mismatch (namestring path) full-so-far)))
+ (or (null mismatch) (= mismatch length)))
+ collect path))
(strings (mapcar #'namestring pathnames))
(first-string (car strings))
(length-common-prefix nil)
@@ -607,9 +622,13 @@
(complete-input stream
#'filename-completer
:allow-any-input t)
- (declare (ignore success))
- (or pathname string)))
+; (declare (ignore success))
+; (or pathname string)))
+ (if success
+ (values pathname 'pathname)
+ (values string 'string))))
+
(defun filepath-filename (pathname)
(if (null (pathname-type pathname))
(pathname-name pathname)
@@ -622,33 +641,44 @@
(pathname-name filepath))
climacs-syntax::*syntaxes*
:test (lambda (x y)
- (member x y :test #'string=))
+ (member x y :test #'string-equal))
:key #'climacs-syntax::syntax-description-pathname-types))
'basic-syntax))
+;; Adapted from cl-fad/PCL
+(defun directory-pathname-p (pathspec)
+ "Returns NIL if PATHSPEC does not designate a directory."
+ (let ((name (pathname-name pathspec))
+ (type (pathname-type pathspec)))
+ (and (or (null name) (eql name :unspecific))
+ (or (null type) (eql type :unspecific)))))
+
(define-named-command com-find-file ()
(let ((filepath (accept 'completable-pathname
- :prompt "Find File"))
- (buffer (make-instance 'climacs-buffer))
- (pane (current-window)))
- (setf (offset (point (buffer pane))) (offset (point pane)))
- (push buffer (buffers *application-frame*))
- (setf (buffer (current-window)) buffer)
- (setf (syntax buffer)
- (make-instance
- (syntax-class-name-for-filepath filepath)
- :buffer (buffer (point pane))))
- ;; Don't want to create the file if it doesn't exist.
- (when (probe-file filepath)
- (with-open-file (stream filepath :direction :input)
- (input-from-stream stream buffer 0)))
- (setf (filepath buffer) filepath
- (name buffer) (filepath-filename filepath)
- (needs-saving buffer) nil)
- (beginning-of-buffer (point pane))
- ;; this one is needed so that the buffer modification protocol
- ;; resets the low and high marks after redisplay
- (redisplay-frame-panes *application-frame*)))
+ :prompt "Find File")))
+ (cond ((directory-pathname-p filepath)
+ (display-message "~A is a directory name." filepath)
+ (beep))
+ (t
+ (let ((buffer (make-instance 'climacs-buffer))
+ (pane (current-window)))
+ (setf (offset (point (buffer pane))) (offset (point pane)))
+ (push buffer (buffers *application-frame*))
+ (setf (buffer (current-window)) buffer)
+ (setf (syntax buffer)
+ (make-instance (syntax-class-name-for-filepath filepath)
+ :buffer (buffer (point pane))))
+ ;; Don't want to create the file if it doesn't exist.
+ (when (probe-file filepath)
+ (with-open-file (stream filepath :direction :input)
+ (input-from-stream stream buffer 0)))
+ (setf (filepath buffer) filepath
+ (name buffer) (filepath-filename filepath)
+ (needs-saving buffer) nil)
+ (beginning-of-buffer (point pane))
+ ;; this one is needed so that the buffer modification protocol
+ ;; resets the low and high marks after redisplay
+ (redisplay-frame-panes *application-frame*))))))
(define-named-command com-insert-file ()
(let ((filename (accept 'completable-pathname
@@ -668,12 +698,17 @@
(let ((filepath (or (filepath buffer)
(accept 'completable-pathname
:prompt "Save Buffer to File"))))
- (with-open-file (stream filepath :direction :output :if-exists :supersede)
- (output-to-stream stream buffer 0 (size buffer)))
- (setf (filepath buffer) filepath
- (name buffer) (filepath-filename filepath))
- (display-message "Wrote: ~a" (filepath buffer))
- (setf (needs-saving buffer) nil)))
+ (cond
+ ((directory-pathname-p filepath)
+ (display-message "~A is a directory." filepath)
+ (beep))
+ (t
+ (with-open-file (stream filepath :direction :output :if-exists :supersede)
+ (output-to-stream stream buffer 0 (size buffer)))
+ (setf (filepath buffer) filepath
+ (name buffer) (filepath-filename filepath))
+ (display-message "Wrote: ~a" (filepath buffer))
+ (setf (needs-saving buffer) nil)))))
(define-named-command com-save-buffer ()
(let ((buffer (buffer (current-window))))
@@ -704,12 +739,16 @@
(let ((filepath (accept 'completable-pathname
:prompt "Write Buffer to File"))
(buffer (buffer (current-window))))
- (with-open-file (stream filepath :direction :output :if-exists :supersede)
- (output-to-stream stream buffer 0 (size buffer)))
- (setf (filepath buffer) filepath
- (name buffer) (filepath-filename filepath)
- (needs-saving buffer) nil)
- (display-message "Wrote: ~a" (filepath buffer))))
+ (cond
+ ((directory-pathname-p filepath)
+ (display-message "~A is a directory name." filepath))
+ (t
+ (with-open-file (stream filepath :direction :output :if-exists :supersede)
+ (output-to-stream stream buffer 0 (size buffer)))
+ (setf (filepath buffer) filepath
+ (name buffer) (filepath-filename filepath)
+ (needs-saving buffer) nil)
+ (display-message "Wrote: ~a" (filepath buffer))))))
(define-presentation-method accept
((type buffer) stream (view textual-view) &key)
@@ -723,41 +762,82 @@
:partial-completers '(#\Space)
:allow-any-input t)
(declare (ignore success))
- (or object
- (car (push (make-instance 'climacs-buffer :name string)
- (buffers *application-frame*))))))
+ (or object string)))
-(define-named-command com-switch-to-buffer ()
- (let ((buffer (accept 'buffer
- :prompt "Switch to buffer"))
- (pane (current-window)))
+(defgeneric switch-to-buffer (buffer))
+
+(defmethod switch-to-buffer ((buffer climacs-buffer))
+ (let* ((buffers (buffers *application-frame*))
+ (position (position buffer buffers))
+ (pane (current-window)))
+ (if position
+ (rotatef (car buffers) (nth position buffers))
+ (push buffer buffers))
(setf (offset (point (buffer pane))) (offset (point pane)))
(setf (buffer pane) buffer)
(full-redisplay pane)))
-(define-named-command com-kill-buffer ()
+(defmethod switch-to-buffer ((name string))
+ (let ((buffer (find name (buffers *application-frame*)
+ :key #'name :test #'string=)))
+ (switch-to-buffer (or buffer
+ (make-instance 'climacs-buffer :name name)))))
+
+;;placeholder
+(defmethod switch-to-buffer ((symbol (eql 'nil)))
+ (switch-to-buffer (second (buffers *application-frame*))))
+
+(define-named-command com-switch-to-buffer ()
+ (let ((buffer (accept 'buffer
+ :prompt "Switch to buffer")))
+ (switch-to-buffer buffer)))
+
+(defgeneric kill-buffer (buffer))
+
+(defmethod kill-buffer ((buffer climacs-buffer))
(with-slots (buffers) *application-frame*
- (let ((buffer (buffer (current-window))))
- (when (and (needs-saving buffer)
- (handler-case (accept 'boolean :prompt "Save buffer first?")
- (error () (progn (beep)
- (display-message "Invalid answer")
- (return-from com-kill-buffer nil)))))
- (com-save-buffer))
- (setf buffers (remove buffer buffers))
- ;; Always need one buffer.
- (when (null buffers)
- (push (make-instance 'climacs-buffer :name "*scratch*")
- buffers))
- (setf (buffer (current-window)) (car buffers)))))
+ (when (and (needs-saving buffer)
+ (handler-case (accept 'boolean :prompt "Save buffer first?")
+ (error () (progn (beep)
+ (display-message "Invalid answer")
+ (return-from kill-buffer nil)))))
+ (com-save-buffer))
+ (setf buffers (remove buffer buffers))
+ ;; Always need one buffer.
+ (when (null buffers)
+ (push (make-instance 'climacs-buffer :name "*scratch*")
+ buffers))
+ (setf (buffer (current-window)) (car buffers))))
+
+(defmethod kill-buffer ((name string))
+ (let ((buffer (find name (buffers *application-frame*)
+ :key #'name :test #'string=)))
+ (when buffer (kill-buffer buffer))))
+
+(defmethod kill-buffer ((symbol (eql 'nil)))
+ (kill-buffer (buffer (current-window))))
+
+(define-named-command com-kill-buffer ()
+ (kill-buffer (buffer (current-window))))
(define-named-command com-full-redisplay ()
(full-redisplay (current-window)))
+(defun load-file (file-name)
+ (cond ((directory-pathname-p file-name)
+ (display-message "~A is a directory name." file-name)
+ (beep))
+ (t
+ (cond ((probe-file file-name)
+ (load file-name))
+ (t
+ (display-message "No such file: ~A" file-name)
+ (beep))))))
+
(define-named-command com-load-file ()
(let ((filepath (accept 'completable-pathname
:prompt "Load File")))
- (load filepath)))
+ (load-file filepath)))
(define-named-command com-beginning-of-buffer ()
(beginning-of-buffer (point (current-window))))
@@ -777,65 +857,76 @@
(beginning-of-buffer (point (current-window)))
(end-of-buffer (mark (current-window))))
+(defun back-to-indentation (mark)
+ (beginning-of-line mark)
+ (loop until (end-of-line-p mark)
+ while (whitespacep (object-after mark))
+ do (forward-object mark)))
+
(define-named-command com-back-to-indentation ()
- (let ((point (point (current-window))))
- (beginning-of-line point)
- (loop until (end-of-line-p point)
- while (whitespacep (object-after point))
- do (incf (offset point)))))
+ (back-to-indentation (point (current-window))))
+
+(defun delete-horizontal-space (mark &optional (backward-only-p nil))
+ (let ((mark2 (clone-mark mark)))
+ (loop until (beginning-of-line-p mark)
+ while (whitespacep (object-before mark))
+ do (backward-object mark))
+ (unless backward-only-p
+ (loop until (end-of-line-p mark2)
+ while (whitespacep (object-after mark2))
+ do (forward-object mark2)))
+ (delete-region mark mark2)))
(define-named-command com-delete-horizontal-space ((backward-only-p
'boolean :prompt "Delete backwards only?"))
- (let* ((point (point (current-window)))
- (mark (clone-mark point)))
- (loop until (beginning-of-line-p point)
- while (whitespacep (object-before point))
- do (backward-object point))
- (unless backward-only-p
- (loop until (end-of-line-p mark)
- while (whitespacep (object-after mark))
- do (forward-object mark)))
- (delete-region point mark)))
+ (delete-horizontal-space (point (current-window)) backward-only-p))
+
+(defun just-one-space (mark count)
+ (let (offset)
+ (loop until (beginning-of-line-p mark)
+ while (whitespacep (object-before mark))
+ do (backward-object mark))
+ (loop until (end-of-line-p mark)
+ while (whitespacep (object-after mark))
+ repeat count do (forward-object mark)
+ finally (setf offset (offset mark)))
+ (loop until (end-of-line-p mark)
+ while (whitespacep (object-after mark))
+ do (forward-object mark))
+ (delete-region offset mark)))
(define-named-command com-just-one-space ((count 'integer :prompt "Number of spaces"))
- (let ((point (point (current-window)))
- offset)
- (loop until (beginning-of-line-p point)
- while (whitespacep (object-before point))
- do (backward-object point))
- (loop until (end-of-line-p point)
- while (whitespacep (object-after point))
- repeat count do (forward-object point)
- finally (setf offset (offset point)))
- (loop until (end-of-line-p point)
- while (whitespacep (object-after point))
- do (forward-object point))
- (delete-region offset point)))
+ (just-one-space (point (current-window)) count))
+
+(defun goto-position (mark pos)
+ (setf (offset mark) pos))
(define-named-command com-goto-position ()
- (setf (offset (point (current-window)))
- (handler-case (accept 'integer :prompt "Goto Position")
- (error () (progn (beep)
- (display-message "Not a valid position")
- (return-from com-goto-position nil))))))
+ (goto-position
+ (point (current-window))
+ (handler-case (accept 'integer :prompt "Goto Position")
+ (error () (progn (beep)
+ (display-message "Not a valid position")
+ (return-from com-goto-position nil))))))
+
+(defun goto-line (mark line-number)
+ (loop with m = (clone-mark (low-mark (buffer mark))
+ :right)
+ initially (beginning-of-buffer m)
+ do (end-of-line m)
+ until (end-of-buffer-p m)
+ repeat (1- line-number)
+ do (incf (offset m))
+ (end-of-line m)
+ finally (beginning-of-line m)
+ (setf (offset mark) (offset m))))
(define-named-command com-goto-line ()
- (loop with mark = (let ((m (clone-mark
- (low-mark (buffer (current-window)))
- :right)))
- (beginning-of-buffer m)
- m)
- do (end-of-line mark)
- until (end-of-buffer-p mark)
- repeat (1- (handler-case (accept 'integer :prompt "Goto Line")
+ (goto-line (point (current-window))
+ (handler-case (accept 'integer :prompt "Goto Line")
(error () (progn (beep)
(display-message "Not a valid line number")
- (return-from com-goto-line nil)))))
- do (incf (offset mark))
- (end-of-line mark)
- finally (beginning-of-line mark)
- (setf (offset (point (current-window)))
- (offset mark))))
+ (return-from com-goto-line nil))))))
(define-named-command com-browse-url ()
(let ((url (accept 'url :prompt "Browse URL")))
@@ -851,15 +942,28 @@
(psetf (offset (mark pane)) (offset (point pane))
(offset (point pane)) (offset (mark pane)))))
+(defgeneric set-syntax (buffer syntax))
+
+(defmethod set-syntax ((buffer climacs-buffer) (syntax syntax))
+ (setf (syntax buffer) syntax))
+
+;;FIXME - what should this specialise on?
+(defmethod set-syntax ((buffer climacs-buffer) syntax)
+ (set-syntax buffer (make-instance syntax :buffer buffer)))
+
+(defmethod set-syntax ((buffer climacs-buffer) (syntax string))
+ (let ((syntax-class (syntax-from-name syntax)))
+ (cond (syntax-class
+ (set-syntax buffer (make-instance syntax-class
+ :buffer buffer)))
+ (t
+ (beep)
+ (display-message "No such syntax: ~A." syntax)))))
+
(define-named-command com-set-syntax ()
(let* ((pane (current-window))
(buffer (buffer pane)))
- (setf (syntax buffer)
- (make-instance (or (accept 'syntax :prompt "Set Syntax")
- (progn (beep)
- (display-message "No such syntax")
- (return-from com-set-syntax nil)))
- :buffer (buffer (point pane))))))
+ (set-syntax buffer (accept 'syntax :prompt "Set Syntax"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@@ -897,7 +1001,7 @@
info pane as its second child. The scroller pane contains a viewport
which contains an extended pane. Return the vbox and the extended pane
as two values.
-If *with-scrollbars nil, omit the scroller."
+If *with-scrollbars* nil, omit the scroller."
(let* ((extended-pane
(make-pane 'extended-pane
@@ -918,11 +1022,11 @@
:width 900))))
(values vbox extended-pane)))
-(define-named-command com-split-window-vertically ()
+(defun split-window-vertically (&optional (pane (current-window)))
(with-look-and-feel-realization
((frame-manager *application-frame*) *application-frame*)
(multiple-value-bind (vbox new-pane) (make-pane-constellation)
- (let* ((current-window (current-window))
+ (let* ((current-window pane)
(constellation-root (if *with-scrollbars*
(parent3 current-window)
(sheet-parent current-window))))
@@ -934,13 +1038,17 @@
(setf *standard-output* new-pane)
(replace-constellation constellation-root vbox t)
(full-redisplay current-window)
- (full-redisplay new-pane)))))
+ (full-redisplay new-pane)
+ new-pane))))
-(define-named-command com-split-window-horizontally ()
+(define-named-command com-split-window-vertically ()
+ (split-window-vertically))
+
+(defun split-window-horizontally (&optional (pane (current-window)))
(with-look-and-feel-realization
((frame-manager *application-frame*) *application-frame*)
(multiple-value-bind (vbox new-pane) (make-pane-constellation)
- (let* ((current-window (current-window))
+ (let* ((current-window pane)
(constellation-root (if *with-scrollbars*
(parent3 current-window)
(sheet-parent current-window))))
@@ -952,21 +1060,31 @@
(setf *standard-output* new-pane)
(replace-constellation constellation-root vbox nil)
(full-redisplay current-window)
- (full-redisplay new-pane)))))
+ (full-redisplay new-pane)
+ new-pane))))
-(define-named-command com-other-window ()
+(define-named-command com-split-window-horizontally ()
+ (split-window-horizontally))
+
+(defun other-window ()
(setf (windows *application-frame*)
(append (cdr (windows *application-frame*))
(list (car (windows *application-frame*)))))
(setf *standard-output* (car (windows *application-frame*))))
-(define-named-command com-single-window ()
+(define-named-command com-other-window ()
+ (other-window))
+
+(defun single-window ()
(loop until (null (cdr (windows *application-frame*)))
do (rotatef (car (windows *application-frame*))
(cadr (windows *application-frame*)))
(com-delete-window))
(setf *standard-output* (car (windows *application-frame*))))
+(define-named-command com-single-window ()
+ (single-window))
+
(define-named-command com-scroll-other-window ()
(let ((other-window (second (windows *application-frame*))))
(when other-window
@@ -977,11 +1095,11 @@
(when other-window
(page-up other-window))))
-(define-named-command com-delete-window ()
+(defun delete-window (&optional (window (current-window)))
(unless (null (cdr (windows *application-frame*)))
(let* ((constellation (if *with-scrollbars*
- (parent3 (current-window))
- (sheet-parent (current-window))))
+ (parent3 window)
+ (sheet-parent window)))
(box (sheet-parent constellation))
(box-children (sheet-children box))
(other (if (eq constellation (first box-children))
@@ -992,7 +1110,8 @@
(first (first children))
(second (second children))
(third (third children)))
- (pop (windows *application-frame*))
+ (setf (windows *application-frame*)
+ (remove window (windows *application-frame*)))
(setf *standard-output* (car (windows *application-frame*)))
(sheet-disown-child box other)
(sheet-disown-child parent box)
@@ -1005,6 +1124,9 @@
(list first second other)
(list first other)))))))
+(define-named-command com-delete-window ()
+ (delete-window))
+
;;;;;;;;;;;;;;;;;;;;
;; Kill ring commands
@@ -1019,7 +1141,7 @@
*kill-ring* (region-to-sequence (mark pane) (point pane)))
(delete-region (mark pane) (point pane))))
-;; Non destructively copies in buffer region to the kill ring
+;; Non destructively copies buffer region to the kill ring
(define-named-command com-copy-region ()
(let ((pane (current-window)))
(kill-ring-standard-push *kill-ring* (region-to-sequence (point pane) (mark pane)))))
@@ -1049,6 +1171,8 @@
;;;
;;; Incremental search
+(make-command-table 'isearch-climacs-table :errorp nil)
+
(defun isearch-command-loop (pane forwardp)
(let ((point (point pane)))
(unless (endp (isearch-states pane))
@@ -1092,15 +1216,15 @@
(unless success
(beep)))))
-(define-named-command com-isearch-mode-forward ()
+(define-named-command com-isearch-forward ()
(display-message "Isearch: ")
(isearch-command-loop (current-window) t))
-(define-named-command com-isearch-mode-backward ()
+(define-named-command com-isearch-backward ()
(display-message "Isearch backward: ")
(isearch-command-loop (current-window) nil))
-(define-named-command com-isearch-append-char ()
+(define-command (com-append-char :name t :command-table isearch-climacs-table) ()
(let* ((pane (current-window))
(states (isearch-states pane))
(string (concatenate 'string
@@ -1112,7 +1236,7 @@
(incf (offset mark)))
(isearch-from-mark pane mark string forwardp)))
-(define-named-command com-isearch-delete-char ()
+(define-command (com-delete-char :name t :command-table isearch-climacs-table) ()
(let* ((pane (current-window)))
(cond ((null (second (isearch-states pane)))
(display-message "Isearch: ")
@@ -1133,7 +1257,7 @@
(search-forward-p state)
(search-string state)))))))
-(define-named-command com-isearch-forward ()
+(define-command (com-forward :name t :command-table isearch-climacs-table) ()
(let* ((pane (current-window))
(point (point pane))
(states (isearch-states pane))
@@ -1143,7 +1267,7 @@
(mark (clone-mark point)))
(isearch-from-mark pane mark string t)))
-(define-named-command com-isearch-backward ()
+(define-command (com-backward :name t :command-table isearch-climacs-table) ()
(let* ((pane (current-window))
(point (point pane))
(states (isearch-states pane))
@@ -1153,13 +1277,27 @@
(mark (clone-mark point)))
(isearch-from-mark pane mark string nil)))
-(define-named-command com-isearch-exit ()
+(define-command (com-exit :name t :command-table isearch-climacs-table) ()
(setf (isearch-mode (current-window)) nil))
+(defun isearch-set-key (gesture command)
+ (add-command-to-command-table command 'isearch-climacs-table
+ :keystroke gesture :errorp nil))
+
+(loop for code from (char-code #\Space) to (char-code #\~)
+ do (isearch-set-key (code-char code) 'com-append-char))
+
+(isearch-set-key '(#\Newline) 'com-exit)
+(isearch-set-key '(#\Backspace) 'com-delete-char)
+(isearch-set-key '(#\s :control) 'com-forward)
+(isearch-set-key '(#\r :control) 'com-backward)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Query replace
+(make-command-table 'query-replace-climacs-table :errorp nil)
+
(defun query-replace-find-next-match (mark string)
(flet ((object-equal (x y)
(and (characterp x)
@@ -1211,7 +1349,7 @@
((setf (query-replace-mode pane) nil))))
(display-message "Replaced ~A occurrence~:P" occurrences)))
-(define-named-command com-query-replace-replace ()
+(define-command (com-replace :name t :command-table query-replace-climacs-table) ()
(declare (special string1 string2 occurrences))
(let* ((pane (current-window))
(point (point pane))
@@ -1235,7 +1373,7 @@
string1 string2)
(setf (query-replace-mode pane) nil))))
-(define-named-command com-query-replace-skip ()
+(define-command (com-skip :name t :command-table query-replace-climacs-table) ()
(declare (special string1 string2))
(let* ((pane (current-window))
(point (point pane)))
@@ -1244,9 +1382,21 @@
string1 string2)
(setf (query-replace-mode pane) nil))))
-(define-named-command com-query-replace-exit ()
+(define-command (com-exit :name t :command-table query-replace-climacs-table) ()
(setf (query-replace-mode (current-window)) nil))
+(defun query-replace-set-key (gesture command)
+ (add-command-to-command-table command 'query-replace-climacs-table
+ :keystroke gesture :errorp nil))
+
+(query-replace-set-key '(#\Newline) 'com-exit)
+(query-replace-set-key '(#\Space) 'com-replace)
+(query-replace-set-key '(#\Backspace) 'com-skip)
+(query-replace-set-key '(#\Rubout) 'com-skip)
+(query-replace-set-key '(#\q) 'com-exit)
+(query-replace-set-key '(#\y) 'com-replace)
+(query-replace-set-key '(#\n) 'com-skip)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Undo/redo
@@ -1301,7 +1451,8 @@
(region-to-sequence offset dabbrev-expansion-mark)
(setf (offset dabbrev-expansion-mark) offset))))
(move))))))))
-
+
+
(define-named-command com-backward-paragraph ((count 'integer :prompt "Number of paragraphs"))
(let* ((pane (current-window))
(point (point pane))
@@ -1448,11 +1599,12 @@
(error () (progn (beep)
(display-message "Empty string")
(return-from com-eval-expression nil)))))
- (result (format nil "~a"
- (handler-case (eval (read-from-string string))
- (error (condition) (progn (beep)
- (display-message "~a" condition)
- (return-from com-eval-expression nil)))))))
+ (values (multiple-value-list
+ (handler-case (eval (read-from-string string))
+ (error (condition) (progn (beep)
+ (display-message "~a" condition)
+ (return-from com-eval-expression nil))))))
+ (result (format nil "~:[; No values~;~:*~{~S~^,~}~]" values)))
(if insertp
(insert-sequence (point (current-window)) result)
(display-message result))))
@@ -1469,21 +1621,6 @@
(syntax (syntax (buffer pane))))
(comment-region syntax point mark)))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;
-;;; For testing purposes
-
-(define-named-command com-reset-profile ()
- #+sbcl (sb-profile:reset)
- #-sbcl nil)
-
-(define-named-command com-report-profile ()
- #+sbcl (sb-profile:report)
- #-sbcl nil)
-
-(define-named-command com-recompile ()
- (asdf:operate 'asdf:load-op :climacs))
-
(define-named-command com-backward-expression ((count 'integer :prompt "Number of expressions"))
(let* ((pane (current-window))
(point (point pane))
@@ -1620,6 +1757,22 @@
(package (climacs-lisp-syntax::package-of syntax)))
(display-message (format nil "~s" package))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; For testing purposes
+
+(define-named-command com-reset-profile ()
+ #+sbcl (sb-profile:reset)
+ #-sbcl nil)
+
+(define-named-command com-report-profile ()
+ #+sbcl (sb-profile:report)
+ #-sbcl nil)
+
+(define-named-command com-recompile ()
+ (asdf:operate 'asdf:load-op :climacs))
+
+
(define-gesture-name :select-other :pointer-button-press (:left :meta) :unique nil)
(define-presentation-translator lisp-string-to-string
@@ -1719,8 +1872,8 @@
(global-set-key '(#\{ :meta :shift) `(com-backward-paragraph ,*numeric-argument-marker*))
(global-set-key '(#\} :meta :shift) `(com-forward-paragraph ,*numeric-argument-marker*))
(global-set-key '(#\h :meta) `(com-mark-paragraph ,*numeric-argument-marker*))
-(global-set-key '(#\s :control) 'com-isearch-mode-forward)
-(global-set-key '(#\r :control) 'com-isearch-mode-backward)
+(global-set-key '(#\s :control) 'com-isearch-forward)
+(global-set-key '(#\r :control) 'com-isearch-backward)
(global-set-key '(#\_ :shift :meta) 'com-redo)
(global-set-key '(#\_ :shift :control) 'com-undo)
(global-set-key '(#\% :shift :meta) 'com-query-replace)
@@ -1952,41 +2105,6 @@
(dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
(dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;
-;;; Isearch command table
-
-(make-command-table 'isearch-climacs-table :errorp nil)
-
-(defun isearch-set-key (gesture command)
- (add-command-to-command-table command 'isearch-climacs-table
- :keystroke gesture :errorp nil))
-
-(loop for code from (char-code #\Space) to (char-code #\~)
- do (isearch-set-key (code-char code) 'com-isearch-append-char))
-
-(isearch-set-key '(#\Newline) 'com-isearch-exit)
-(isearch-set-key '(#\Backspace) 'com-isearch-delete-char)
-(isearch-set-key '(#\s :control) 'com-isearch-forward)
-(isearch-set-key '(#\r :control) 'com-isearch-backward)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;
-;;; Query replace command table
-
-(make-command-table 'query-replace-climacs-table :errorp nil)
-
-(defun query-replace-set-key (gesture command)
- (add-command-to-command-table command 'query-replace-climacs-table
- :keystroke gesture :errorp nil))
-
-(query-replace-set-key '(#\Newline) 'com-query-replace-exit)
-(query-replace-set-key '(#\Space) 'com-query-replace-replace)
-(query-replace-set-key '(#\Backspace) 'com-query-replace-skip)
-(query-replace-set-key '(#\Rubout) 'com-query-replace-skip)
-(query-replace-set-key '(#\q) 'com-query-replace-exit)
-(query-replace-set-key '(#\y) 'com-query-replace-replace)
-(query-replace-set-key '(#\n) 'com-query-replace-skip)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@@ -2002,3 +2120,4 @@
(add-command-to-command-table command 'c-c-climacs-table
:keystroke gesture :errorp nil))
+(c-c-set-key '(#\l :control) 'com-load-file)
1
0

[climacs-cvs] CVS update: climacs/ttcn3-syntax.lisp climacs/slidemacs.lisp climacs/prolog-syntax.lisp climacs/pane.lisp climacs/packages.lisp climacs/lisp-syntax.lisp climacs/html-syntax.lisp climacs/gui.lisp climacs/fundamental-syntax.lisp climacs/cl-syntax.lisp
by dmurray@common-lisp.net 15 Aug '05
by dmurray@common-lisp.net 15 Aug '05
15 Aug '05
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv6402
Modified Files:
ttcn3-syntax.lisp slidemacs.lisp prolog-syntax.lisp pane.lisp
packages.lisp lisp-syntax.lisp html-syntax.lisp gui.lisp
fundamental-syntax.lisp cl-syntax.lisp
Log Message:
Factored out cursor display from syntaxes to a display-cursor
method on basic-syntax. Also added a display-mark method,
a mark-visible-p slot on climacs-pane, and a command
com-toggle-visible-mark to turn display of the mark on
and off - useful for developing marking commands.
Date: Tue Aug 16 01:31:22 2005
Author: dmurray
Index: climacs/ttcn3-syntax.lisp
diff -u climacs/ttcn3-syntax.lisp:1.2 climacs/ttcn3-syntax.lisp:1.3
--- climacs/ttcn3-syntax.lisp:1.2 Thu May 26 10:31:53 2005
+++ climacs/ttcn3-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -442,15 +442,6 @@
do (let ((token (lexeme lexer start-token-index)))
(display-parse-tree token syntax pane))
(incf start-token-index))))))))
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column (column-number (point pane)))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p
- (make-rgb-color 0.7 0.7 0.7) +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p)))
Index: climacs/slidemacs.lisp
diff -u climacs/slidemacs.lisp:1.6 climacs/slidemacs.lisp:1.7
--- climacs/slidemacs.lisp:1.6 Tue Jun 21 18:51:05 2005
+++ climacs/slidemacs.lisp Tue Aug 16 01:31:22 2005
@@ -444,14 +444,5 @@
do (let ((token (lexeme lexer start-token-index)))
(display-parse-tree token syntax pane))
(incf start-token-index))))))))
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column (column-number (point pane)))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p
- (make-rgb-color 0.7 0.7 0.7) +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p)))
Index: climacs/prolog-syntax.lisp
diff -u climacs/prolog-syntax.lisp:1.21 climacs/prolog-syntax.lisp:1.22
--- climacs/prolog-syntax.lisp:1.21 Fri May 27 15:25:01 2005
+++ climacs/prolog-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -1265,20 +1265,8 @@
do (let ((token (lexeme lexer start-token-index)))
(display-parse-tree token syntax pane))
(incf start-token-index))))))))
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column
- ;; FIXME: surely this should be more abstracted?
- (buffer-display-column
- (buffer (point pane)) (offset (point pane))
- (round (tab-width pane) (space-width pane))))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p +red+ +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p)))
#|
(climacs-gui::define-named-command com-inspect-lex ()
Index: climacs/pane.lisp
diff -u climacs/pane.lisp:1.28 climacs/pane.lisp:1.29
--- climacs/pane.lisp:1.28 Mon Jul 18 00:40:37 2005
+++ climacs/pane.lisp Tue Aug 16 01:31:22 2005
@@ -231,6 +231,7 @@
(isearch-previous-string :initform nil :accessor isearch-previous-string)
(query-replace-mode :initform nil :accessor query-replace-mode)
(query-replace-state :initform nil :accessor query-replace-state)
+ (mark-visible-p :initform nil :accessor mark-visible-p)
(full-redisplay-p :initform nil :accessor full-redisplay-p)
(cache :initform (let ((cache (make-instance 'standard-flexichain)))
(insert* cache 0 nil)
@@ -460,37 +461,31 @@
(beginning-of-line (point pane))
(empty-cache cache)))))
-(defun display-cache (pane cursor-ink)
- (let* ((medium (sheet-medium pane))
- (style (medium-text-style medium))
- (height (text-style-height style medium)))
- (with-slots (top bot scan cache cursor-x cursor-y) pane
- (loop with start-offset = (offset top)
- for id from 0 below (nb-elements cache)
- do (setf scan start-offset)
- (updating-output
- (pane :unique-id (element* cache id)
- :cache-value (if (<= start-offset
- (offset (point pane))
- (+ start-offset (length (element* cache id))))
- (cons nil nil)
- (element* cache id))
- :cache-test #'eq)
- (display-line pane (element* cache id) start-offset
- (syntax (buffer pane)) (stream-default-view pane)))
- (incf start-offset (1+ (length (element* cache id)))))
- (when (mark= scan (point pane))
- (multiple-value-bind (x y) (stream-cursor-position pane)
- (setf cursor-x x
- cursor-y y)))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink cursor-ink)))))
+(defun display-cache (pane)
+ (with-slots (top bot scan cache cursor-x cursor-y) pane
+ (loop with start-offset = (offset top)
+ for id from 0 below (nb-elements cache)
+ do (setf scan start-offset)
+ (updating-output
+ (pane :unique-id (element* cache id)
+ :cache-value (if (<= start-offset
+ (offset (point pane))
+ (+ start-offset (length (element* cache id))))
+ (cons nil nil)
+ (element* cache id))
+ :cache-test #'eq)
+ (display-line pane (element* cache id) start-offset
+ (syntax (buffer pane)) (stream-default-view pane)))
+ (incf start-offset (1+ (length (element* cache id)))))
+ (when (mark= scan (point pane))
+ (multiple-value-bind (x y) (stream-cursor-position pane)
+ (setf cursor-x x
+ cursor-y y)))))
(defmethod redisplay-pane-with-syntax ((pane climacs-pane) (syntax basic-syntax) current-p)
- (display-cache pane (if current-p +red+ +blue+)))
+ (display-cache pane)
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p))
(defgeneric redisplay-pane (pane current-p))
@@ -508,3 +503,47 @@
(defmethod full-redisplay ((pane climacs-pane))
(setf (full-redisplay-p pane) t))
+
+(defgeneric display-cursor (pane syntax current-p))
+
+(defmethod display-cursor ((pane climacs-pane) (syntax basic-syntax) current-p)
+ (with-slots (top) pane
+ (let* ((cursor-line (number-of-lines-in-region top (point pane)))
+ (style (medium-text-style pane))
+ (ascent (text-style-ascent style pane))
+ (descent (text-style-descent style pane))
+ (height (+ ascent descent))
+ (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
+ (cursor-column
+ (buffer-display-column
+ (buffer (point pane)) (offset (point pane))
+ (round (tab-width pane) (space-width pane))))
+ (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
+ (updating-output (pane :unique-id -1)
+ (draw-rectangle* pane
+ (1- cursor-x) cursor-y
+ (+ cursor-x 2) (+ cursor-y ascent descent)
+ :ink (if current-p +red+ +blue+))))))
+
+(defgeneric display-mark (pane syntax))
+
+(defmethod display-mark ((pane climacs-pane) (syntax basic-syntax))
+ (with-slots (top bot) pane
+ (let ((mark (mark pane)))
+ (when (< (offset top) (offset mark) (offset bot))
+ (let* ((mark-line (number-of-lines-in-region top mark))
+ (style (medium-text-style pane))
+ (ascent (text-style-ascent style pane))
+ (descent (text-style-descent style pane))
+ (height (+ ascent descent))
+ (mark-y (+ (* mark-line (+ height (stream-vertical-spacing pane)))))
+ (mark-column
+ (buffer-display-column
+ (buffer mark) (offset mark)
+ (round (tab-width pane) (space-width pane))))
+ (mark-x (* mark-column (text-style-width (medium-text-style pane) pane))))
+ (updating-output (pane :unique-id -2)
+ (draw-rectangle* pane
+ (1- mark-x) mark-y
+ (+ mark-x 2) (+ mark-y ascent descent)
+ :ink +green+)))))))
\ No newline at end of file
Index: climacs/packages.lisp
diff -u climacs/packages.lisp:1.76 climacs/packages.lisp:1.77
--- climacs/packages.lisp:1.76 Sun Aug 14 20:09:42 2005
+++ climacs/packages.lisp Tue Aug 16 01:31:22 2005
@@ -141,6 +141,8 @@
(:export #:climacs-buffer #:needs-saving #:filepath
#:climacs-pane #:point #:mark
#:redisplay-pane #:full-redisplay
+ #:display-cursor
+ #:display-mark
#:page-down #:page-up
#:top #:bot
#:tab-space-count #:space-width #:tab-width
@@ -151,6 +153,7 @@
#:isearch-mode #:isearch-states #:isearch-previous-string
#:query-replace-state #:string1 #:string2
#:query-replace-mode
+ #:mark-visible-p
#:with-undo
#:url))
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.31 climacs/lisp-syntax.lisp:1.32
--- climacs/lisp-syntax.lisp:1.31 Mon Aug 15 23:24:55 2005
+++ climacs/lisp-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -1374,23 +1374,8 @@
(let ((*current-faces* *standard-faces*))
(with-slots (stack-top) syntax
(display-parse-tree stack-top syntax pane)))
- (with-slots (top) pane
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (style (medium-text-style pane))
- (ascent (text-style-ascent style pane))
- (descent (text-style-descent style pane))
- (height (+ ascent descent))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column
- (buffer-display-column
- (buffer (point pane)) (offset (point pane))
- (round (tab-width pane) (space-width pane))))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) cursor-y
- (+ cursor-x 2) (+ cursor-y ascent descent)
- :ink (if current-p +red+ +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Index: climacs/html-syntax.lisp
diff -u climacs/html-syntax.lisp:1.31 climacs/html-syntax.lisp:1.32
--- climacs/html-syntax.lisp:1.31 Thu May 26 10:31:53 2005
+++ climacs/html-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -798,14 +798,6 @@
do (let ((token (lexeme lexer start-token-index)))
(display-parse-tree token syntax pane))
(incf start-token-index))))))))
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column (column-number (point pane)))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p +red+ +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p)))
Index: climacs/gui.lisp
diff -u climacs/gui.lisp:1.176 climacs/gui.lisp:1.177
--- climacs/gui.lisp:1.176 Sun Aug 14 20:09:42 2005
+++ climacs/gui.lisp Tue Aug 16 01:31:22 2005
@@ -1640,6 +1640,9 @@
(define-named-command com-accept-lisp-string ()
(display-message (format nil "~s" (accept 'lisp-string))))
+(define-named-command com-toggle-visible-mark ()
+ (setf (mark-visible-p (current-window)) (not (mark-visible-p (current-window)))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Dead-escape command tables
Index: climacs/fundamental-syntax.lisp
diff -u climacs/fundamental-syntax.lisp:1.1 climacs/fundamental-syntax.lisp:1.2
--- climacs/fundamental-syntax.lisp:1.1 Tue Jul 19 12:02:02 2005
+++ climacs/fundamental-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -108,23 +108,6 @@
pane (- tab-width (mod x tab-width)) 0))))
(incf start))))
-
-(defun display-cursor (pane current-p)
- (with-slots (top) pane
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column
- (buffer-display-column
- (buffer (point pane)) (offset (point pane))
- (round (tab-width pane) (space-width pane))))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p +red+ +blue+))))))
-
(defmethod display-line (pane mark)
(setf mark (clone-mark mark))
(let ((saved-offset nil)
@@ -202,7 +185,8 @@
:cache-value line
:cache-test #'eq)
(display-line pane (start-mark (element* lines i))))))))))
- (display-cursor pane current-p))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Index: climacs/cl-syntax.lisp
diff -u climacs/cl-syntax.lisp:1.14 climacs/cl-syntax.lisp:1.15
--- climacs/cl-syntax.lisp:1.14 Thu May 26 10:31:53 2005
+++ climacs/cl-syntax.lisp Tue Aug 16 01:31:22 2005
@@ -1125,17 +1125,8 @@
do (let ((token (lexeme lexer start-token-index)))
(display-parse-tree token syntax pane))
(incf start-token-index))))))))
- (let* ((cursor-line (number-of-lines-in-region top (point pane)))
- (height (text-style-height (medium-text-style pane) pane))
- (cursor-y (+ (* cursor-line (+ height (stream-vertical-spacing pane)))))
- (cursor-column (column-number (point pane)))
- (cursor-x (* cursor-column (text-style-width (medium-text-style pane) pane))))
- (updating-output (pane :unique-id -1)
- (draw-rectangle* pane
- (1- cursor-x) (- cursor-y (* 0.2 height))
- (+ cursor-x 2) (+ cursor-y (* 0.8 height))
- :ink (if current-p
- (make-rgb-color 0.7 0.7 0.7) +blue+))))))
+ (when (mark-visible-p pane) (display-mark pane syntax))
+ (display-cursor pane syntax current-p)))
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv29381
Modified Files:
lisp-syntax.lisp
Log Message:
Changed a couple of indent-lambda-lists to indent-ordinary-lambda-list.
Date: Mon Aug 15 23:24:56 2005
Author: dmurray
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.30 climacs/lisp-syntax.lisp:1.31
--- climacs/lisp-syntax.lisp:1.30 Mon Aug 15 17:52:55 2005
+++ climacs/lisp-syntax.lisp Mon Aug 15 23:24:55 2005
@@ -1891,7 +1891,7 @@
(indent-list syntax (elt-form (children tree) 2) (cdr path)))
(3
;; in the lambda-list
- (indent-lambda-list syntax (elt-form (children tree) 3) (cdr path)))
+ (indent-ordinary-lambda-list syntax (elt-form (children tree) 3) (cdr path)))
(t
;; in the options or method specifications
(indent-list syntax (elt-form (children tree) (car path)) (cdr path))))))
@@ -1911,7 +1911,7 @@
(< (car path) lambda-list-pos))
(indent-list syntax (elt-form (children tree) (car path)) (cdr path)))
((= (car path) lambda-list-pos)
- (indent-lambda-list syntax (elt-form (children tree) (car path)) (cdr path)))
+ (indent-ordinary-lambda-list syntax (elt-form (children tree) (car path)) (cdr path)))
(t
(indent-form syntax (elt-form (children tree) (car path)) (cdr path))))))
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv6465
Modified Files:
lisp-syntax.lisp
Log Message:
Indentation code now 'ignores' comments.
That is:
(defun ;comment
foo ;comment
()
nil)
indents correctly. Indentation code should now use
first-form, rest-forms, elt-form on lists of tokens
(such as children of trees) instead of car, cdr and
elt. See patches - this is a simple textual substitution.
Date: Mon Aug 15 17:52:56 2005
Author: dmurray
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.29 climacs/lisp-syntax.lisp:1.30
--- climacs/lisp-syntax.lisp:1.29 Sun Aug 14 20:09:42 2005
+++ climacs/lisp-syntax.lisp Mon Aug 15 17:52:55 2005
@@ -1082,21 +1082,34 @@
"Returns the first non-comment in list."
(find-if-not #'(lambda (item) (typep item 'comment)) list))
+(defun rest-forms (list)
+ "Returns the remainder of the list after the first non-comment,
+stripping leading comments."
+ (loop for rest on list
+ count (not (typep (car rest) 'comment))
+ into forms
+ until (= forms 2)
+ finally (return rest)))
+
(defun nth-form (n list)
"Returns the nth non-comment in list."
(loop for item in list
count (not (typep item 'comment))
into forms
- until (= forms n)
+ until (> forms n)
finally (return item)))
+(defun elt-form (list n)
+ "Returns the nth non-comment in list."
+ (nth-form n list))
+
(defun second-form (list)
"Returns the second non-comment in list."
- (nth-form 2 list))
+ (nth-form 1 list))
(defun third-form (list)
"Returns the third non-comment in list."
- (nth-form 3 list))
+ (nth-form 2 list))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@@ -1717,14 +1730,14 @@
(and (null (cdr path)) (zerop (car path))))
(values tree 0))
((null (cdr path))
- (values (elt (children tree) (1- (car path))) 0))
- (t (indent-form syntax (elt (children tree) (car path)) (cdr path)))))
+ (values (elt-form (children tree) (1- (car path))) 0))
+ (t (indent-form syntax (elt-form (children tree) (car path)) (cdr path)))))
(defmethod indent-form ((syntax lisp-syntax) (tree list-form) path)
(if (= (car path) 1)
;; before first element
(values tree 1)
- (let ((first-child (elt (children tree) 1)))
+ (let ((first-child (elt-form (children tree) 1)))
(cond ((and (typep first-child 'token-mixin)
(token-to-symbol syntax first-child))
(compute-list-indentation syntax (token-to-symbol syntax first-child) tree path))
@@ -1732,12 +1745,12 @@
;; top level
(if (= (car path) 2)
;; indent like first element
- (values (elt (children tree) 1) 0)
+ (values (elt-form (children tree) 1) 0)
;; indent like second element
- (values (elt (children tree) 2) 0)))
+ (values (elt-form (children tree) 2) 0)))
(t
;; inside a subexpression
- (indent-form syntax (elt (children tree) (car path)) (cdr path)))))))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path)))))))
(defmethod indent-form ((syntax lisp-syntax) (tree string-form) path)
(values tree 1))
@@ -1751,8 +1764,11 @@
(defmethod indent-form ((syntax lisp-syntax) (tree long-comment-form) path)
(values tree 0))
+(defmethod indent-form ((syntax lisp-syntax) (tree quote-form) path)
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path)))
+
(defmethod indent-form ((syntax lisp-syntax) (tree backquote-form) path)
- (indent-form syntax (elt (children tree) (car path)) (cdr path)))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path)))
(defmethod indent-binding ((syntax lisp-syntax) tree path)
(if (null (cdr path))
@@ -1762,11 +1778,11 @@
(values tree 1))
((= (car path) 2)
;; between variable and value
- (values (elt (children tree) 1) 0))
+ (values (elt-form (children tree) 1) 0))
(t
;; after value
- (values (elt (children tree) 2) 0)))
- (indent-form syntax (elt (children tree) (car path)) (cdr path))))
+ (values (elt-form (children tree) 2) 0)))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))
(defmethod indent-bindings ((syntax lisp-syntax) tree path)
(if (null (cdr path))
@@ -1775,20 +1791,20 @@
;; before first binding, indent 1
(values tree 1)
;; after some bindings, align with first binding
- (values (elt (children tree) 1) 0))
+ (values (elt-form (children tree) 1) 0))
;; inside a bind form
- (indent-binding syntax (elt (children tree) (car path)) (cdr path))))
+ (indent-binding syntax (elt-form (children tree) (car path)) (cdr path))))
(defmethod compute-list-indentation ((syntax lisp-syntax) symbol tree path)
(if (null (cdr path))
;; top level
(if (= (car path) 2)
;; indent like first child
- (values (elt (children tree) 1) 0)
+ (values (elt-form (children tree) 1) 0)
;; indent like second child
- (values (elt (children tree) 2) 0))
+ (values (elt-form (children tree) 2) 0))
;; inside a subexpression
- (indent-form syntax (elt (children tree) (car path)) (cdr path))))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))
(defmacro define-list-indentor (name element-indentor)
`(defun ,name (syntax tree path)
@@ -1798,9 +1814,9 @@
;; indent one more than the list
(values tree 1)
;; indent like the first element
- (values (elt (children tree) 1) 0))
+ (values (elt-form (children tree) 1) 0))
;; inside an element
- (,element-indentor syntax (elt (children tree) (car path)) (cdr path)))))
+ (,element-indentor syntax (elt-form (children tree) (car path)) (cdr path)))))
;;; line up the elements vertically
(define-list-indentor indent-list indent-list)
@@ -1821,8 +1837,9 @@
(values tree (if (<= (car path) ,(length template)) 4 2)))
,@(loop for fun in (cdr template)
for i from 2
- collect `((= (car path) ,i) (,fun syntax (elt (children tree) ,i) (cdr path))))
- (t (indent-form syntax (elt (children tree) (car path)) (cdr path))))))
+ collect `((= (car path) ,i)
+ (,fun syntax (elt-form (children tree) ,i) (cdr path))))
+ (t (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))))
(define-simple-indentor (progn))
(define-simple-indentor (prog1 indent-form))
@@ -1855,13 +1872,13 @@
(case (car path)
((2 3)
;; in the class name or superclasses respectively
- (indent-list syntax (elt (children tree) (car path)) (cdr path)))
+ (indent-list syntax (elt-form (children tree) (car path)) (cdr path)))
(4
;; in the slot specs
- (indent-slot-specs syntax (elt (children tree) 4) (cdr path)))
+ (indent-slot-specs syntax (elt-form (children tree) 4) (cdr path)))
(t
;; this is an approximation, might want to do better
- (indent-list syntax (elt (children tree) (car path)) (cdr path))))))
+ (indent-list syntax (elt-form (children tree) (car path)) (cdr path))))))
(defmethod compute-list-indentation
((syntax lisp-syntax) (symbol (eql 'defgeneric)) tree path)
@@ -1871,18 +1888,19 @@
(case (car path)
(2
;; in the function name
- (indent-list syntax (elt (children tree) 2) (cdr path)))
+ (indent-list syntax (elt-form (children tree) 2) (cdr path)))
(3
;; in the lambda-list
- (indent-lambda-list syntax (elt (children tree) 3) (cdr path)))
+ (indent-lambda-list syntax (elt-form (children tree) 3) (cdr path)))
(t
;; in the options or method specifications
- (indent-list syntax (elt (children tree) (car path)) (cdr path))))))
+ (indent-list syntax (elt-form (children tree) (car path)) (cdr path))))))
(defmethod compute-list-indentation
((syntax lisp-syntax) (symbol (eql 'defmethod)) tree path)
(let ((lambda-list-pos (position-if (lambda (x) (typep x 'list-form))
- (children tree))))
+ (remove-if
+ (lambda (x) (typep x 'comment)) (children tree)))))
(cond ((null (cdr path))
;; top level
(values tree (if (or (null lambda-list-pos)
@@ -1891,11 +1909,11 @@
2)))
((or (null lambda-list-pos)
(< (car path) lambda-list-pos))
- (indent-list syntax (elt (children tree) (car path)) (cdr path)))
+ (indent-list syntax (elt-form (children tree) (car path)) (cdr path)))
((= (car path) lambda-list-pos)
- (indent-lambda-list syntax (elt (children tree) (car path)) (cdr path)))
+ (indent-lambda-list syntax (elt-form (children tree) (car path)) (cdr path)))
(t
- (indent-form syntax (elt (children tree) (car path)) (cdr path))))))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))))
(defun indent-clause (syntax tree path)
(if (null (cdr path))
@@ -1903,8 +1921,8 @@
(case (car path)
(1 (values tree 1))
(2 (values tree 1))
- (t (values (elt (children tree) 2) 0)))
- (indent-form syntax (elt (children tree) (car path)) (cdr path))))
+ (t (values (elt-form (children tree) 2) 0)))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))
(defmethod compute-list-indentation
((syntax lisp-syntax) (symbol (eql 'cond)) tree path)
@@ -1914,9 +1932,9 @@
;; after `cond'
(values tree 2)
;; indent like the first clause
- (values (elt (children tree) 2) 0))
+ (values (elt-form (children tree) 2) 0))
;; inside a clause
- (indent-clause syntax (elt (children tree) (car path)) (cdr path))))
+ (indent-clause syntax (elt-form (children tree) (car path)) (cdr path))))
(macrolet ((def (symbol)
`(defmethod compute-list-indentation
@@ -1925,8 +1943,8 @@
(case (car path)
(2 (values tree 4))
(3 (values tree 2))
- (t (values (elt (children tree) 3) 0)))
- (indent-clause syntax (elt (children tree) (car path)) (cdr path))))))
+ (t (values (elt-form (children tree) 3) 0)))
+ (indent-clause syntax (elt-form (children tree) (car path)) (cdr path))))))
(def case)
(def ccase)
(def ecase)
@@ -1942,19 +1960,19 @@
;; the symbol existing in the current image. (Arguably, too,
;; this is a broken indentation form because it doesn't carry
;; over to the implicit tagbodies in macros such as DO.
- (if (typep (elt (children tree) (car path)) 'token-mixin)
+ (if (typep (elt-form (children tree) (car path)) 'token-mixin)
(values tree 2)
(values tree 4))
- (indent-form syntax (elt (children tree) (car path)) (cdr path))))
+ (indent-form syntax (elt-form (children tree) (car path)) (cdr path))))
(defun compute-path-in-trees (trees n offset)
(cond ((or (null trees)
- (>= (start-offset (car trees)) offset))
+ (>= (start-offset (first-form trees)) offset))
(list n))
- ((or (< (start-offset (car trees)) offset (end-offset (car trees)))
- (typep (car trees) 'incomplete-form-mixin))
- (cons n (compute-path-in-tree (car trees) offset)))
- (t (compute-path-in-trees (cdr trees) (1+ n) offset))))
+ ((or (< (start-offset (first-form trees)) offset (end-offset (first-form trees)))
+ (typep (first-form trees) 'incomplete-form-mixin))
+ (cons n (compute-path-in-tree (first-form trees) offset)))
+ (t (compute-path-in-trees (rest-forms trees) (1+ n) offset))))
(defun compute-path-in-tree (tree offset)
(if (null (children tree))
1
0

[climacs-cvs] CVS update: climacs/packages.lisp climacs/lisp-syntax.lisp climacs/kill-ring.lisp climacs/gui.lisp
by dmurray@common-lisp.net 14 Aug '05
by dmurray@common-lisp.net 14 Aug '05
14 Aug '05
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv16088
Modified Files:
packages.lisp lisp-syntax.lisp kill-ring.lisp gui.lisp
Log Message:
Added com-just-one-space (M-Space), com-scroll-other-window-up (C-M-V),
com-append-next-kill (M-C-w).
Also, I think I've fixed expression-navigation funkiness.
Date: Sun Aug 14 20:09:42 2005
Author: dmurray
Index: climacs/packages.lisp
diff -u climacs/packages.lisp:1.75 climacs/packages.lisp:1.76
--- climacs/packages.lisp:1.75 Sun Aug 14 14:12:35 2005
+++ climacs/packages.lisp Sun Aug 14 20:09:42 2005
@@ -122,7 +122,8 @@
(defpackage :climacs-kill-ring
(:use :clim-lisp :flexichain)
- (:export #:kill-ring #:kill-ring-length #:kill-ring-max-size
+ (:export #:kill-ring #:kill-ring-length #:kill-ring-max-size
+ #:append-next-p
#:reset-yank-position #:rotate-yank-position #:kill-ring-yank
#:kill-ring-standard-push #:kill-ring-concatenating-push
#:kill-ring-reverse-concatenating-push))
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.28 climacs/lisp-syntax.lisp:1.29
--- climacs/lisp-syntax.lisp:1.28 Sun Aug 14 10:56:58 2005
+++ climacs/lisp-syntax.lisp Sun Aug 14 20:09:42 2005
@@ -1393,7 +1393,9 @@
((and (>= offset (end-offset first))
(or (null rest)
(<= offset (start-offset (first-form rest)))))
- (return (let ((potential-form (form-before-in-children (children first) offset)))
+ (return (let ((potential-form
+ (when (typep first 'list-form)
+ (form-before-in-children (children first) offset))))
(or potential-form
(when (typep first 'form)
first)))))
@@ -1438,7 +1440,7 @@
((<= offset (start-offset child))
(return nil))
(t nil))))
-
+
(defun form-around (syntax offset)
(with-slots (stack-top) syntax
(if (or (null (start-offset stack-top))
Index: climacs/kill-ring.lisp
diff -u climacs/kill-ring.lisp:1.7 climacs/kill-ring.lisp:1.8
--- climacs/kill-ring.lisp:1.7 Fri Aug 5 14:40:56 2005
+++ climacs/kill-ring.lisp Sun Aug 14 20:09:42 2005
@@ -31,7 +31,9 @@
:accessor kill-ring-chain
:initform (make-instance 'standard-cursorchain))
(yankpoint :type left-sticky-flexicursor
- :accessor kill-ring-cursor))
+ :accessor kill-ring-cursor)
+ (append-next-p :type boolean :initform nil
+ :accessor append-next-p))
(:documentation "A class for all kill rings"))
(defmethod initialize-instance :after((kr kill-ring) &rest args)
@@ -115,14 +117,17 @@
(setf (cursor-pos curs) pos))))
(defmethod kill-ring-standard-push ((kr kill-ring) vector)
- (let ((chain (kill-ring-chain kr)))
- (if (>= (kill-ring-length kr)
- (kill-ring-max-size kr))
- (progn
- (pop-end chain)
- (push-start chain vector))
- (push-start chain vector)))
- (reset-yank-position kr))
+ (cond ((append-next-p kr)
+ (kill-ring-concatenating-push kr vector)
+ (setf (append-next-p kr) nil))
+ (t (let ((chain (kill-ring-chain kr)))
+ (if (>= (kill-ring-length kr)
+ (kill-ring-max-size kr))
+ (progn
+ (pop-end chain)
+ (push-start chain vector))
+ (push-start chain vector)))
+ (reset-yank-position kr))))
(defmethod kill-ring-concatenating-push ((kr kill-ring) vector)
(let ((chain (kill-ring-chain kr)))
Index: climacs/gui.lisp
diff -u climacs/gui.lisp:1.175 climacs/gui.lisp:1.176
--- climacs/gui.lisp:1.175 Sun Aug 14 14:11:21 2005
+++ climacs/gui.lisp Sun Aug 14 20:09:42 2005
@@ -797,6 +797,20 @@
do (forward-object mark)))
(delete-region point mark)))
+(define-named-command com-just-one-space ((count 'integer :prompt "Number of spaces"))
+ (let ((point (point (current-window)))
+ offset)
+ (loop until (beginning-of-line-p point)
+ while (whitespacep (object-before point))
+ do (backward-object point))
+ (loop until (end-of-line-p point)
+ while (whitespacep (object-after point))
+ repeat count do (forward-object point)
+ finally (setf offset (offset point)))
+ (loop until (end-of-line-p point)
+ while (whitespacep (object-after point))
+ do (forward-object point))
+ (delete-region offset point)))
(define-named-command com-goto-position ()
(setf (offset (point (current-window)))
@@ -958,6 +972,11 @@
(when other-window
(page-down other-window))))
+(define-named-command com-scroll-other-window-up ()
+ (let ((other-window (second (windows *application-frame*))))
+ (when other-window
+ (page-up other-window))))
+
(define-named-command com-delete-window ()
(unless (null (cdr (windows *application-frame*)))
(let* ((constellation (if *with-scrollbars*
@@ -1023,6 +1042,9 @@
(return-from com-resize-kill-ring nil))))))
(setf (kill-ring-max-size *kill-ring*) size)))
+(define-named-command com-append-next-kill ()
+ (setf (append-next-p *kill-ring*) t))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Incremental search
@@ -1662,6 +1684,7 @@
(global-set-key '(#\Space :control) 'com-set-mark)
(global-set-key '(#\y :control) 'com-yank)
(global-set-key '(#\w :control) 'com-kill-region)
+(global-set-key '(#\w :control :meta) 'com-append-next-kill)
(global-set-key '(#\e :meta) `(com-forward-sentence ,*numeric-argument-marker*))
(global-set-key '(#\a :meta) `(com-backward-sentence ,*numeric-argument-marker*))
(global-set-key '(#\k :meta) `(com-kill-sentence ,*numeric-argument-marker*))
@@ -1678,10 +1701,12 @@
(global-set-key '(#\v :control) 'com-page-down)
(global-set-key '(#\v :meta) 'com-page-up)
(global-set-key '(#\v :control :meta) 'com-scroll-other-window)
+(global-set-key '(#\V :control :meta :shift) 'com-scroll-other-window-up)
(global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
(global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
(global-set-key '(#\m :meta) 'com-back-to-indentation)
(global-set-key '(#\\ :meta) `(com-delete-horizontal-space ,*numeric-argument-p*))
+(global-set-key '(#\Space :meta) `(com-just-one-space ,*numeric-argument-marker*))
(global-set-key '(#\^ :shift :meta) 'com-delete-indentation)
(global-set-key '(#\q :meta) 'com-fill-paragraph)
(global-set-key '(#\d :meta) `(com-kill-word ,*numeric-argument-marker*))
1
0

[climacs-cvs] CVS update: climacs/syntax.lisp climacs/packages.lisp
by dmurray@common-lisp.net 14 Aug '05
by dmurray@common-lisp.net 14 Aug '05
14 Aug '05
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv24141
Modified Files:
syntax.lisp packages.lisp
Log Message:
The other parts of the list movement commands.
Date: Sun Aug 14 14:12:35 2005
Author: dmurray
Index: climacs/syntax.lisp
diff -u climacs/syntax.lisp:1.55 climacs/syntax.lisp:1.56
--- climacs/syntax.lisp:1.55 Fri Aug 5 14:40:56 2005
+++ climacs/syntax.lisp Sun Aug 14 14:12:35 2005
@@ -67,6 +67,31 @@
(defgeneric forward-sentence (mark syntax))
+(defgeneric forward-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+(defgeneric backward-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+(defgeneric down-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+(defgeneric backward-down-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+(defgeneric backward-up-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+(defgeneric up-list (mark syntax)
+ (:method (mark syntax)
+ (error 'no-such-operation)))
+
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Commenting
Index: climacs/packages.lisp
diff -u climacs/packages.lisp:1.74 climacs/packages.lisp:1.75
--- climacs/packages.lisp:1.74 Fri Aug 5 10:07:17 2005
+++ climacs/packages.lisp Sun Aug 14 14:12:35 2005
@@ -113,6 +113,9 @@
#:redisplay-pane-with-syntax
#:backward-paragraph #:forward-paragraph
#:backward-sentence #:forward-sentence
+ #:forward-list #:backward-list
+ #:down-list #:up-list
+ #:backward-down-list #:backward-up-list
#:syntax-line-comment-string
#:line-comment-region #:comment-region
#:line-uncomment-region #:uncomment-region))
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv24094
Modified Files:
gui.lisp
Log Message:
Added com-backward-kill-expression (M-C-Backspace),
com-kill-expression (M-C-k), com-forward-list (M-C-n),
com-backward-list (M-C-p), com-down-list (M-C-d),
com-backward-up-list (M-C-u), com-up-list,
com-backward-down-list.
Also a (currently empty) C-c command table,
and a hacky way of choosing my favourite look over the
standard look (by setting climacs-gui::*with-scrollbars*
to nil before starting).
Date: Sun Aug 14 14:11:21 2005
Author: dmurray
Index: climacs/gui.lisp
diff -u climacs/gui.lisp:1.174 climacs/gui.lisp:1.175
--- climacs/gui.lisp:1.174 Mon Aug 8 20:32:02 2005
+++ climacs/gui.lisp Sun Aug 14 14:11:21 2005
@@ -49,6 +49,9 @@
(:default-initargs
:height 20 :max-height 20 :min-height 20))
+(defparameter *with-scrollbars* t
+ "If T, classic look and feel. If NIL, stripped-down look (:")
+
(define-application-frame climacs (standard-application-frame
esa-frame-mixin)
((buffers :initform '() :accessor buffers))
@@ -70,8 +73,10 @@
(buffers *application-frame*) (list (buffer extended-pane)))
(vertically ()
- (scrolling ()
- extended-pane)
+ (if *with-scrollbars*
+ (scrolling ()
+ extended-pane)
+ extended-pane)
info-pane)))
(int (make-pane 'climacs-minibuffer-pane :width 900)))
(:layouts
@@ -103,9 +108,24 @@
(declare (ignore frame))
(let* ((master-pane (master-pane pane))
(buf (buffer master-pane))
- (name-info (format nil " ~a ~a Syntax: ~a~a~a~a ~a"
+ (size (size buf))
+ (top (top master-pane))
+ (bot (bot master-pane))
+ (name-info (format nil " ~a ~a~:[~30t~a~;~*~] ~:[(~;Syntax: ~]~a~a~a~a~:[)~;~] ~a"
(if (needs-saving buf) "**" "--")
(name buf)
+ *with-scrollbars*
+ (cond ((and (mark= size bot)
+ (mark= 0 top))
+ "")
+ ((mark= size bot)
+ "Bot")
+ ((mark= 0 top)
+ "Top")
+ (t (format nil "~a%"
+ (round (* 100 (/ (offset top)
+ size))))))
+ *with-scrollbars*
(name (syntax buf))
(if (slot-value master-pane 'overwrite-mode)
" Ovwrt"
@@ -116,6 +136,7 @@
(if (isearch-mode master-pane)
" Isearch"
"")
+ *with-scrollbars*
(if (recordingp *application-frame*)
"Def"
""))))
@@ -585,7 +606,6 @@
(multiple-value-bind (pathname success string)
(complete-input stream
#'filename-completer
- :partial-completers '(#\Space)
:allow-any-input t)
(declare (ignore success))
(or pathname string)))
@@ -842,9 +862,9 @@
(sheet-disown-child parent constellation)
(let ((new (if vertical-p
(vertically ()
- constellation adjust additional-constellation)
+ (1/2 constellation) adjust (1/2 additional-constellation))
(horizontally ()
- constellation adjust additional-constellation))))
+ (1/2 constellation) adjust (1/2 additional-constellation)))))
(sheet-adopt-child parent new)
(reorder-sheets parent
(if (eq constellation first)
@@ -862,7 +882,9 @@
"make a vbox containing a scroller pane as its first child and an
info pane as its second child. The scroller pane contains a viewport
which contains an extended pane. Return the vbox and the extended pane
-as two values"
+as two values.
+If *with-scrollbars nil, omit the scroller."
+
(let* ((extended-pane
(make-pane 'extended-pane
:width 900 :height 400
@@ -873,7 +895,10 @@
:command-table 'global-climacs-table))
(vbox
(vertically ()
- (scrolling () extended-pane)
+ (if *with-scrollbars*
+ (scrolling ()
+ extended-pane)
+ extended-pane)
(make-pane 'climacs-info-pane
:master-pane extended-pane
:width 900))))
@@ -884,7 +909,9 @@
((frame-manager *application-frame*) *application-frame*)
(multiple-value-bind (vbox new-pane) (make-pane-constellation)
(let* ((current-window (current-window))
- (constellation-root (parent3 current-window)))
+ (constellation-root (if *with-scrollbars*
+ (parent3 current-window)
+ (sheet-parent current-window))))
(setf (offset (point (buffer current-window))) (offset (point current-window))
(buffer new-pane) (buffer current-window)
(auto-fill-mode new-pane) (auto-fill-mode current-window)
@@ -900,7 +927,9 @@
((frame-manager *application-frame*) *application-frame*)
(multiple-value-bind (vbox new-pane) (make-pane-constellation)
(let* ((current-window (current-window))
- (constellation-root (parent3 current-window)))
+ (constellation-root (if *with-scrollbars*
+ (parent3 current-window)
+ (sheet-parent current-window))))
(setf (offset (point (buffer current-window))) (offset (point current-window))
(buffer new-pane) (buffer current-window)
(auto-fill-mode new-pane) (auto-fill-mode current-window)
@@ -931,7 +960,9 @@
(define-named-command com-delete-window ()
(unless (null (cdr (windows *application-frame*)))
- (let* ((constellation (parent3 (current-window)))
+ (let* ((constellation (if *with-scrollbars*
+ (parent3 (current-window))
+ (sheet-parent (current-window))))
(box (sheet-parent constellation))
(box-children (sheet-children box))
(other (if (eq constellation (first box-children))
@@ -1449,12 +1480,85 @@
(define-named-command com-mark-expression ((count 'integer :prompt "Number of expressions"))
(let* ((pane (current-window))
- (point (point pane))
- (mark (mark pane))
- (syntax (syntax (buffer pane))))
- (unless (eq (previous-command pane) 'com-mark-expression)
- (setf (offset mark) (offset point)))
- (loop repeat count do (forward-expression mark syntax))))
+ (point (point pane))
+ (mark (mark pane))
+ (syntax (syntax (buffer pane))))
+ (unless (eq (previous-command pane) 'com-mark-expression)
+ (setf (offset mark) (offset point)))
+ (if (plusp count)
+ (loop repeat count do (forward-expression mark syntax))
+ (loop repeat (- count) do (backward-expression mark syntax)))))
+
+(define-named-command com-kill-expression ((count 'integer :prompt "Number of expressions"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (mark (clone-mark point))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (forward-expression mark syntax))
+ (loop repeat (- count) do (backward-expression mark syntax)))
+ (kill-ring-standard-push *kill-ring* (region-to-sequence mark point))
+ (delete-region mark point)))
+
+(define-named-command com-backward-kill-expression
+ ((count 'integer :prompt "Number of expressions"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (mark (clone-mark point))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (backward-expression mark syntax))
+ (loop repeat (- count) do (forward-expression mark syntax)))
+ (kill-ring-standard-push *kill-ring* (region-to-sequence mark point))
+ (delete-region mark point)))
+
+(define-named-command com-forward-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (forward-list point syntax))
+ (loop repeat (- count) do (backward-list point syntax)))))
+
+(define-named-command com-backward-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (backward-list point syntax))
+ (loop repeat (- count) do (forward-list point syntax)))))
+
+(define-named-command com-down-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (down-list point syntax))
+ (loop repeat (- count) do (backward-down-list point syntax)))))
+
+(define-named-command com-backward-down-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (backward-down-list point syntax))
+ (loop repeat (- count) do (down-list point syntax)))))
+
+(define-named-command com-backward-up-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (backward-up-list point syntax))
+ (loop repeat (- count) do (up-list point syntax)))))
+
+(define-named-command com-up-list ((count 'integer :prompt "Number of lists"))
+ (let* ((pane (current-window))
+ (point (point pane))
+ (syntax (syntax (buffer pane))))
+ (if (plusp count)
+ (loop repeat count do (up-list point syntax))
+ (loop repeat (- count) do (backward-up-list point syntax)))))
(define-named-command com-eval-defun ()
(let* ((pane (current-window))
@@ -1613,6 +1717,12 @@
(global-set-key '(#\b :control :meta) `(com-backward-expression ,*numeric-argument-marker*))
(global-set-key '(#\f :control :meta) `(com-forward-expression ,*numeric-argument-marker*))
+(global-set-key '(#\Backspace :control :meta) `(com-backward-kill-expression ,*numeric-argument-marker*))
+(global-set-key '(#\k :control :meta) `(com-kill-expression ,*numeric-argument-marker*))
+(global-set-key '(#\n :control :meta) `(com-forward-list ,*numeric-argument-marker*))
+(global-set-key '(#\p :control :meta) `(com-backward-list ,*numeric-argument-marker*))
+(global-set-key '(#\d :control :meta) `(com-down-list ,*numeric-argument-marker*))
+(global-set-key '(#\u :control :meta) `(com-backward-up-list ,*numeric-argument-marker*))
(global-set-key '(#\x :control :meta) 'com-eval-defun)
(global-set-key '(#\a :control :meta) `(com-beginning-of-definition ,*numeric-argument-marker*))
(global-set-key '(#\e :control :meta) `(com-end-of-definition ,*numeric-argument-marker*))
@@ -1849,3 +1959,18 @@
(query-replace-set-key '(#\q) 'com-query-replace-exit)
(query-replace-set-key '(#\y) 'com-query-replace-replace)
(query-replace-set-key '(#\n) 'com-query-replace-skip)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
+;;; C-c command table
+
+(make-command-table 'c-c-climacs-table :errorp nil)
+
+(add-menu-item-to-command-table 'global-climacs-table "C-c"
+ :menu 'c-c-climacs-table
+ :keystroke '(#\c :control))
+
+(defun c-c-set-key (gesture command)
+ (add-command-to-command-table command 'c-c-climacs-table
+ :keystroke gesture :errorp nil))
+
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv10993
Modified Files:
lisp-syntax.lisp
Log Message:
Some list movement commands (forward- backward- up- backward-up-
down-list).
Date: Sun Aug 14 10:56:59 2005
Author: dmurray
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.27 climacs/lisp-syntax.lisp:1.28
--- climacs/lisp-syntax.lisp:1.27 Sat Aug 13 22:26:44 2005
+++ climacs/lisp-syntax.lisp Sun Aug 14 10:56:58 2005
@@ -1461,6 +1461,72 @@
(setf (offset mark) (end-offset potential-form))
(error 'no-expression))))
+(defmethod forward-list (mark (syntax lisp-syntax))
+ (loop for start = (offset mark)
+ then (end-offset potential-form)
+ for potential-form = (or (form-after syntax start)
+ (form-around syntax start))
+ until (null potential-form)
+ when (typep potential-form 'list-form)
+ do (setf (offset mark) (end-offset potential-form))
+ (return)
+ finally (error 'no-expression)))
+
+(defmethod backward-list (mark (syntax lisp-syntax))
+ (loop for start = (offset mark)
+ then (start-offset potential-form)
+ for potential-form = (or (form-before syntax start)
+ (form-around syntax start))
+ until (null potential-form)
+ when (typep potential-form 'list-form)
+ do (setf (offset mark) (start-offset potential-form))
+ (return)
+ finally (error 'no-expression)))
+
+(defmethod down-list (mark (syntax lisp-syntax))
+ (loop for start = (offset mark)
+ then (end-offset potential-form)
+ for potential-form = (or (form-after syntax start)
+ (form-around syntax start))
+ until (null potential-form)
+ when (typep potential-form 'list-form)
+ do (setf (offset mark) (1+ (start-offset potential-form)))
+ (return)
+ finally (error 'no-expression)))
+
+(defmethod backward-down-list (mark (syntax lisp-syntax))
+ (loop for start = (offset mark)
+ then (start-offset potential-form)
+ for potential-form = (or (form-before syntax start)
+ (form-around syntax start))
+ until (null potential-form)
+ when (typep potential-form 'list-form)
+ do (setf (offset mark) (1- (end-offset potential-form)))
+ (return)
+ finally (error 'no-expression)))
+
+(defmethod backward-up-list (mark (syntax lisp-syntax))
+ (let ((form (or (form-around syntax (offset mark))
+ (form-before syntax (offset mark))
+ (form-after syntax (offset mark)))))
+ (if form
+ (let ((parent (parent form)))
+ (if (typep parent 'list-form)
+ (setf (offset mark) (start-offset parent))
+ (error 'no-expression)))
+ (error 'no-expression))))
+
+(defmethod up-list (mark (syntax lisp-syntax))
+ (let ((form (or (form-around syntax (offset mark))
+ (form-before syntax (offset mark))
+ (form-after syntax (offset mark)))))
+ (if form
+ (let ((parent (parent form)))
+ (if (typep parent 'list-form)
+ (setf (offset mark) (end-offset parent))
+ (error 'no-expression)))
+ (error 'no-expression))))
+
(defmethod eval-defun (mark (syntax lisp-syntax))
(with-slots (stack-top) syntax
(loop for form in (children stack-top)
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv27817
Modified Files:
lisp-syntax.lisp
Log Message:
implement a bunch of indentation methods for various lisp forms.
Date: Sat Aug 13 22:26:44 2005
Author: crhodes
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.26 climacs/lisp-syntax.lisp:1.27
--- climacs/lisp-syntax.lisp:1.26 Sat Aug 13 20:33:10 2005
+++ climacs/lisp-syntax.lisp Sat Aug 13 22:26:44 2005
@@ -1683,6 +1683,9 @@
(defmethod indent-form ((syntax lisp-syntax) (tree long-comment-form) path)
(values tree 0))
+(defmethod indent-form ((syntax lisp-syntax) (tree backquote-form) path)
+ (indent-form syntax (elt (children tree) (car path)) (cdr path)))
+
(defmethod indent-binding ((syntax lisp-syntax) tree path)
(if (null (cdr path))
;; top level
@@ -1736,7 +1739,12 @@
;;; for now the same as indent-list, but try to do better with
;;; optional parameters with default values
-(define-list-indentor indent-lambda-list indent-list)
+(define-list-indentor indent-ordinary-lambda-list indent-list)
+;;; again, can do better
+(define-list-indentor indent-macro-lambda-list indent-list)
+;;; FIXME: also BOA, DEFSETF, DEFTYPE, SPECIALIZED, GENERIC-FUNCTION,
+;;; DESTRUCTURING, DEFINE-MODIFY-MACRO and
+;;; DEFINE-METHOD-COMBINATION-ARGUMENTS
(defmacro define-simple-indentor (template)
`(defmethod compute-list-indentation
@@ -1748,14 +1756,25 @@
collect `((= (car path) ,i) (,fun syntax (elt (children tree) ,i) (cdr path))))
(t (indent-form syntax (elt (children tree) (car path)) (cdr path))))))
+(define-simple-indentor (progn))
(define-simple-indentor (prog1 indent-form))
+(define-simple-indentor (prog2 indent-form indent-form))
+(define-simple-indentor (locally))
(define-simple-indentor (let indent-bindings))
(define-simple-indentor (let* indent-bindings))
-(define-simple-indentor (defun indent-list indent-lambda-list))
-(define-simple-indentor (defmacro indent-list indent-lambda-list))
-(define-simple-indentor (with-slots indent-list))
+(define-simple-indentor (multiple-value-bind indent-list indent-form))
+(define-simple-indentor (defun indent-list indent-ordinary-lambda-list))
+(define-simple-indentor (defmacro indent-list indent-macro-lambda-list))
+(define-simple-indentor (with-slots indent-bindings indent-form))
+(define-simple-indentor (with-accessors indent-bindings indent-form))
(define-simple-indentor (when indent-form))
(define-simple-indentor (unless indent-form))
+(define-simple-indentor (print-unreadable-object indent-list))
+(define-simple-indentor (defvar indent-form))
+(define-simple-indentor (defparameter indent-form))
+(define-simple-indentor (defconstant indent-form))
+
+;;; non-simple-cases: LOOP, MACROLET, FLET, LABELS
;;; do this better
(define-list-indentor indent-slot-specs indent-list)
@@ -1810,7 +1829,14 @@
(t
(indent-form syntax (elt (children tree) (car path)) (cdr path))))))
-(define-list-indentor indent-clause indent-form)
+(defun indent-clause (syntax tree path)
+ (if (null (cdr path))
+ ;; top level
+ (case (car path)
+ (1 (values tree 1))
+ (2 (values tree 1))
+ (t (values (elt (children tree) 2) 0)))
+ (indent-form syntax (elt (children tree) (car path)) (cdr path))))
(defmethod compute-list-indentation
((syntax lisp-syntax) (symbol (eql 'cond)) tree path)
@@ -1823,6 +1849,35 @@
(values (elt (children tree) 2) 0))
;; inside a clause
(indent-clause syntax (elt (children tree) (car path)) (cdr path))))
+
+(macrolet ((def (symbol)
+ `(defmethod compute-list-indentation
+ ((syntax lisp-syntax) (symbol (eql ',symbol)) tree path)
+ (if (null (cdr path))
+ (case (car path)
+ (2 (values tree 4))
+ (3 (values tree 2))
+ (t (values (elt (children tree) 3) 0)))
+ (indent-clause syntax (elt (children tree) (car path)) (cdr path))))))
+ (def case)
+ (def ccase)
+ (def ecase)
+ (def typecase)
+ (def ctypecase)
+ (def etypecase))
+
+(defmethod compute-list-indentation
+ ((syntax lisp-syntax) (symbol (eql 'tagbody)) tree path)
+ (if (null (cdr path))
+ ;; this TOKEN-MIXIN test is not quite right. It should be a
+ ;; test for symbolness of the token, but it shouldn't depend on
+ ;; the symbol existing in the current image. (Arguably, too,
+ ;; this is a broken indentation form because it doesn't carry
+ ;; over to the implicit tagbodies in macros such as DO.
+ (if (typep (elt (children tree) (car path)) 'token-mixin)
+ (values tree 2)
+ (values tree 4))
+ (indent-form syntax (elt (children tree) (car path)) (cdr path))))
(defun compute-path-in-trees (trees n offset)
(cond ((or (null trees)
1
0
Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv21006
Modified Files:
lisp-syntax.lisp
Log Message:
Small changes to movement by expression and display of reader
conditionals to exploit new handling of comments.
Date: Sat Aug 13 20:33:11 2005
Author: dmurray
Index: climacs/lisp-syntax.lisp
diff -u climacs/lisp-syntax.lisp:1.25 climacs/lisp-syntax.lisp:1.26
--- climacs/lisp-syntax.lisp:1.25 Wed Aug 10 18:38:45 2005
+++ climacs/lisp-syntax.lisp Sat Aug 13 20:33:10 2005
@@ -1076,6 +1076,30 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
+;;; accessing parser forms
+
+(defun first-form (list)
+ "Returns the first non-comment in list."
+ (find-if-not #'(lambda (item) (typep item 'comment)) list))
+
+(defun nth-form (n list)
+ "Returns the nth non-comment in list."
+ (loop for item in list
+ count (not (typep item 'comment))
+ into forms
+ until (= forms n)
+ finally (return item)))
+
+(defun second-form (list)
+ "Returns the second non-comment in list."
+ (nth-form 2 list))
+
+(defun third-form (list)
+ "Returns the third non-comment in list."
+ (nth-form 3 list))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
;;; display
(defvar *white-space-start* nil)
@@ -1258,7 +1282,7 @@
(defmethod display-parse-tree ((parse-symbol reader-conditional-positive-form)
(syntax lisp-syntax) pane)
- (let ((conditional (second (children parse-symbol))))
+ (let ((conditional (second-form (children parse-symbol))))
(if (eval-feature-conditional conditional syntax)
(call-next-method)
(let ((*current-faces* *reader-conditional-faces*))
@@ -1267,7 +1291,7 @@
(defmethod display-parse-tree ((parse-symbol reader-conditional-negative-form)
(syntax lisp-syntax) pane)
- (let ((conditional (second (children parse-symbol))))
+ (let ((conditional (second-form (children parse-symbol))))
(if (eval-feature-conditional conditional syntax)
(let ((*current-faces* *reader-conditional-faces*))
(with-face (:reader-conditional)
@@ -1296,11 +1320,16 @@
(defmethod eval-feature-conditional ((conditional list-form) (syntax lisp-syntax))
(let ((children (children conditional)))
- (when (third children)
+ (when (third-form children)
(flet ((eval-fc (conditional)
(funcall #'eval-feature-conditional conditional syntax)))
- (let* ((type (second children))
- (conditionals (butlast (nthcdr 2 children)))
+ (let* ((type (second-form children))
+ (conditionals (butlast
+ (nthcdr
+ 2
+ (remove-if
+ #'(lambda (child) (typep child 'comment))
+ children))))
(type-string (coerce (buffer-sequence (buffer syntax)
(start-offset type)
(end-offset type))
@@ -1355,14 +1384,15 @@
;;; exploit the parse
(defun form-before-in-children (children offset)
- (loop for (first second) on children
+ (loop for (first . rest) on children
+ unless (typep first 'comment)
do (cond ((< (start-offset first) offset (end-offset first))
(return (if (null (children first))
nil
(form-before-in-children (children first) offset))))
((and (>= offset (end-offset first))
- (or (null second)
- (<= offset (start-offset second))))
+ (or (null rest)
+ (<= offset (start-offset (first-form rest)))))
(return (let ((potential-form (form-before-in-children (children first) offset)))
(or potential-form
(when (typep first 'form)
@@ -1378,16 +1408,17 @@
(defun form-after-in-children (children offset)
(loop for child in children
- do (cond ((< (start-offset child) offset (end-offset child))
- (return (if (null (children child))
- nil
- (form-after-in-children (children child) offset))))
- ((<= offset (start-offset child))
- (return (let ((potential-form (form-after-in-children (children child) offset)))
- (or potential-form
- (when (typep child 'form)
- child)))))
- (t nil))))
+ unless (typep child 'comment)
+ do (cond ((< (start-offset child) offset (end-offset child))
+ (return (if (null (children child))
+ nil
+ (form-after-in-children (children child) offset))))
+ ((<= offset (start-offset child))
+ (return (let ((potential-form (form-after-in-children (children child) offset)))
+ (or potential-form
+ (when (typep child 'form)
+ child)))))
+ (t nil))))
(defun form-after (syntax offset)
(with-slots (stack-top) syntax
@@ -1398,6 +1429,7 @@
(defun form-around-in-children (children offset)
(loop for child in children
+ unless (typep child 'comment)
do (cond ((< (start-offset child) offset (end-offset child))
(return (if (null (children child))
(when (typep child 'form)
@@ -1444,14 +1476,14 @@
(with-slots (stack-top) syntax
(loop for form in (children stack-top)
with last-toplevel-list = nil
- when (and (typep form 'list-form)
+ when (and (typep form 'form)
(mark< mark (end-offset form)))
do (if (mark< (start-offset form) mark)
(setf (offset mark) (start-offset form))
(when last-toplevel-list form
(setf (offset mark) (start-offset last-toplevel-list))))
(return t)
- when (typep form 'list-form)
+ when (typep form 'form)
do (setf last-toplevel-list form)
finally (when last-toplevel-list form
(setf (offset mark) (start-offset last-toplevel-list))))))
@@ -1459,7 +1491,7 @@
(defmethod end-of-definition (mark (syntax lisp-syntax))
(with-slots (stack-top) syntax
(loop for form in (children stack-top)
- when (and (typep form 'list-form)
+ when (and (typep form 'form)
(mark< mark (end-offset form)))
do (setf (offset mark) (end-offset form))
(loop-finish))))
1
0