From: Shawn Betts Date: Tue, 4 Dec 2007 10:17:33 +0000 (-0800) Subject: add command move-end-of-line X-Git-Url: https://repo.or.cz/w/lice.git/commitdiff_plain/21154bdbcb75a7c795f05e1d7c11a3abcbb60333 add command move-end-of-line --- diff --git a/src/lisp/simple.lisp b/src/lisp/simple.lisp index f7cef39..171ade6 100644 --- a/src/lisp/simple.lisp +++ b/src/lisp/simple.lisp @@ -443,7 +443,6 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t." (constrain-to-field (point) orig (/= arg 1) t nil))))) - (defcommand end-of-line ((&optional (n 1)) :prefix) "Move point to end of current line. @@ -479,6 +478,40 @@ to t." (t (return)))) nil)) +(defcommand move-end-of-line ((arg) + :prefix) + "Move point to end of current line as displayed. +\(If there's an image in the line, this disregards newlines +which are part of the text that the image rests on.) + +With argument ARG not nil or 1, move forward ARG - 1 lines first. +If point reaches the beginning or end of buffer, it stops there. +To ignore intangibility, bind `inhibit-point-motion-hooks' to t." + (or arg (setq arg 1)) + (let (done) + (while (not done) + (let ((newpos + (save-excursion + (let ((goal-column 0)) + (and (line-move arg t) + (not (bobp)) + (progn + (while (and (not (bobp)) (line-move-invisible-p (1- (point)))) + (goto-char (previous-char-property-change (point)))) + (backward-char 1))) + (point))))) + (goto-char newpos) + (if (and (> (point) newpos) + (eq (preceding-char) #\Newline)) + (backward-char 1) + (if (and (> (point) newpos) (not (eobp)) + (not (eq (following-char) #\Newline))) + ;; If we skipped something intangible + ;; and now we're not really at eol, + ;; keep going. + (setq arg 1) + (setq done t))))))) + (defcommand execute-extended-command ((prefix) :raw-prefix) "Read a user command from the minibuffer."