Commit 31627e17 authored by larry's avatar larry
Browse files

v9: ASDF file, highlight font changed, bug fixes

7/28/2008

* Created rudimentary ASDF file: lw-vim-mode.asd.
* Removed vimmode.lisp.

6/13/2008

* Updated doc file.
* Fixed bug in with-move.  Fixes problem with `w`, `e`, and related commands.
* Changed name of font-face used to highlight searches.  Changed that face
  to be a yellow background instead of white-on-black.  Don't know how to say
  "take the current foreground and add a yellow background".

darcs-hash:a9b44872a232a53bff82d8b157085cf82b491af5
parent 50b3dd22
......@@ -229,7 +229,7 @@
(move-point form-start point)
(character-offset point length)
(font-lock-unfontify-region form-start point)
(font-lock-apply-highlight form-start point *font-lock-inverse-face*)))))
(font-lock-apply-highlight form-start point *font-lock-highlight-search-face*)))))
)
)))
......
7/28/2008
* Created rudimentary ASDF file: lw-vim-mode.asd.
* Removed vimmode.lisp.
6/13/2008
* Updated doc file.
* Fixed bug in with-move. Fixes problem with `w`, `e`, and related commands.
* Changed name of font-face used to highlight searches. Changed that face
to be a yellow background instead of white-on-black. Don't know how to say
"take the current foreground and add a yellow background".
v8, 6/13/2008
General changes:
......
......@@ -208,11 +208,10 @@
(beginning-of-buffer-command p))
(back-to-indentation-command p))
;; Mostly exists to set linewise
(def-vim-move "Vim Move Over Whole Line" (p) :linewise :exclusive "" ""
(line-start b-vim-point-before-movement)
(when (and p (> p 1))
(line-offset (current-point) (1- p)))
(line-end (current-point)))
(line-offset (current-point) (1- p))))
(def-vim-move "Vim Move Over Inner Word" (p) nil :inclusive "" ""
(move-over-word p :word t))
......@@ -240,7 +239,8 @@
(def-vim-movement-pending "Vim Yank Motion" (begin end) "" ""
(save-linewise-status)
(vim-action-over-motion #'save-region-command begin end))
(vim-action-over-motion #'save-region-command begin end)
)
;; Basically maps D to d$
(def-vim-change "Vim Kill To End Of Line" (p) "" ""
......
......@@ -12,12 +12,14 @@ Items marked with a leading (\*) have *significantly* different semantics than i
Items marked with a (+) are not in Vim. (Obviously this is not to say that Vim can't do them, just that the mapping doesn't exist.)
Some of these mappings are just my own favorites (like C-F12 to save all files), but they're in there, so I should document them.
Some of these mappings are just my own favorites (like C-F12 to save all files), but they're in there, so I've documented them.
Installation:
(change-directory "path/to/files")
(load "vimmode")
* Load ASDF. Documenting ASDF is beyond the scope of this document.
See <http://www.cliki.net/asdf>.
* Link lw-vim-mode.asd into one of your ASDF system directories.
* (asdf:operate 'asdf:load-op :lw-vim-mode)
Changing modes:
......@@ -95,10 +97,10 @@ Cut/paste, yank/put, kill/un-kill:
Buffers/windows:
* New buffer: `:n`
* New window: `C-w`,`n` (that's C-w, then n)
* Previous/next window: `C-w`,`k` / `C-w`,`j`
* Close window: `C-w`,`c`
* (*)New buffer: `:n`
* (*)New window: `C-w`,`n` (that's C-w, then n)
* (*)Previous/next window: `C-w`,`k` / `C-w`,`j`
* (*)Close window: `C-w`,`c`
* (*)List buffers: `:ls`,Return `F7`
* (*)Select buffer: `:b`,Space
* (*)Next buffer: `:bn`,Return `C-F10`
......
......@@ -135,9 +135,9 @@
(cdr list)
(cons :not list)))
(skip-current ()
(loop for attrib in '((:whitespace)
(,word-type)
(:not :whitespace ,word-type))
(loop for attrib in (list '(:whitespace)
(list ,word-type)
(list :not :whitespace ,word-type))
until (vim-char-attribute attrib ,point)
finally return (must (vim-find-attribute ,forward (invert attrib) ,point))))
(fix-endp (endp)
......@@ -214,7 +214,7 @@
(points-to-string start end))))
(defun move-over-word (p type end)
(vim-offset 1 type nil b-vim-point-before-movement)
(vim-offset 1 type nil b-vim-begin-pending-motion)
(vim-offset (or p 1) type t (current-point) :end end))
(defun vim-read-a-character ()
......@@ -256,15 +256,31 @@
(defun finish-pending-motion (move)
(let ((saved-vim-movement-pending b-vim-movement-pending))
(flet ((command (p)
(save-excursion
(setf b-vim-movement-pending saved-vim-movement-pending)
(move-point b-vim-point-before-movement (current-point))
(funcall move p)
(unless (exclusive)
(character-offset (current-point) 1))
(funcall *vim-pending-action*
b-vim-point-before-movement
(current-point)))))
(setf b-vim-movement-pending saved-vim-movement-pending)
(move-point b-vim-point-before-movement (current-point))
(move-point b-vim-begin-pending-motion (current-point))
(let ((offset (point-column b-vim-point-before-movement)))
(funcall move p)
(unless (exclusive)
(character-offset (current-point) 1))
(funcall *vim-pending-action*
b-vim-begin-pending-motion
(current-point))
(if (point-buffer b-vim-point-before-movement) ; point deleted?
(move-point (current-point) b-vim-point-before-movement) ; no
(progn
; FIXME: Extend with-move to do this more elegantly
(let ((point (current-point)))
(with-point ((limit point))
(line-start point)
(line-end limit)
(loop for count below offset
while (point< point limit)
do (character-offset point 1))
(when (point> point limit)
(character-offset point -1))))
; ; make a new point
(setf b-vim-point-before-movement (copy-point (current-point))))))))
(command nil)
(setf *vim-last-action* #'command
*vim-repeat-multiplier* nil
......@@ -355,7 +371,7 @@
(defun vim-action-over-motion (action begin end)
;; Make sure begin and end are distinct objects, different from each other
;; and different from (current-point).
(with-point ((begin begin)
(with-point ((begin begin :before-insert)
(end end))
; (format t "~&starting Vim Delete Motion: begin is ~S, end is ~S~%" begin end)
(when (point< end begin)
......@@ -370,8 +386,7 @@
(line-start begin)
(line-end end)
(character-offset end 1))
; (format t "begin is ~S, end is ~S~%" begin end)
; (format t "point is ~S, begin is ~S, end is ~S~%" (current-point) begin end)
(move-point (current-point) begin)
(set-current-mark end)
(funcall action nil)
(move-point (current-point) begin)))
(funcall action nil)))
......@@ -20,10 +20,12 @@ like dj.")
(defvar *vim-last-inserted-text* nil
"A copy of the text most recently inserted.")
(defvar *font-lock-inverse-face*
(editor:make-face 'font-lock-inverse-face
:if-exists t
:inverse-p t))
;; I'd really like a font that says "change the background to yellow but leave
;; the foreeground alone. Using :foreground nil doesn't seem to work. Oh Well.
(defvar *font-lock-highlight-search-face*
(editor:make-face 'font-lock-highlight-search-face
:if-exists :overwrite
:background :yellow))
(defvar *vim-default-char-attributes* (make-hash-table))
......
......@@ -57,7 +57,9 @@
(def-vim-var-definer def-vim-window-var :window (current-window))
(def-vim-buffer-var b-vim-point-before-movement (copy-point (current-point))
"The point before a movement command.")
"The point before a movement command. Return to this point after a pending motion.")
(def-vim-buffer-var b-vim-begin-pending-motion (copy-point (current-point))
"Move this around to change where a pending motion command starts.")
(def-vim-buffer-var b-vim-exclusive t
"Defines whether the current movement command is exclusive")
(def-vim-buffer-var b-vim-linewise t
......@@ -107,3 +109,6 @@ We must know if we're collecting a count so we can process #\0 (zero) correctly.
(def-vim-buffer-var b-vim-char-attributes
(copy-hash-table *vim-default-char-attributes*))
(def-vim-buffer-var b-vim-visual-mode-type nil
"The type of visual mode: nil, :char, :line, :block.")
(in-package :cl-user)
; To compile this in a stand-alone Lisp w/out loading the environment, use
; lw -build =(print '(compile-file "vimmode")')
; (The =() is zsh-specific though). You could also say
; echo '(compile-file "vimmode")' > /tmp/build ; lw -build /tmp/build
#+nil
(eval-when (:compile-toplevel :load-toplevel :execute)
(asdf:oos 'asdf:load-op :cells))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro compile-load (file)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(compile-file-if-needed ,file :load t))))
(compile-load "packages")
(compile-load "wrap-editor")
(compile-load "vars")
(compile-load "classes")
(compile-load "vim-vars")
(compile-load "def-stuff")
(compile-load "macros")
(compile-load "functions")
(compile-load "commands")
(compile-load "bindings")
; Convenient scratchpad ...
#+nil
(bind-key "Vim Test" #(#\C-\, #\C-\.))
#+nil
(defcommand "Vim Test" (p) "" ""
(format t "'~A'~%" (current-word)))
......@@ -106,9 +106,11 @@
open-line-command
point<
point<=
point>
point>=
point/=
point-buffer
point-column
points-to-string
previous-line-command
prompt-for-character*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment