all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#13273: 24.3.50; [PATCH] enhancement request: repeatable `visual-line-mode' line movements
@ 2012-12-24 22:27 Drew Adams
  2012-12-25 17:41 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Drew Adams @ 2012-12-24 22:27 UTC (permalink / raw)
  To: 13273

[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]

The attached patch does the following:
 
1. Redefines commands `beginning-of-visual-line' and
   `end-of-visual-line', so that they are repeatable.
 
2. Redefines commands `beginning-of-line' and `end-of-line', so that
   they are repeatable.
 
3. Removes the remapping of commands `move-beginning-of-line' and
   `move-end-of-line' to `beginning-of-visual-line' and
   `end-of-visual-line' - see next.
 
4. In place of those remappings, makes these key bindings for
   `visual-line-mode':
 
   * `home' - `beginning-of-line'
   * `end'  - `end-of-line'
   * `C-a'  - `beginning-of-visual-line'
   * `C-e'  - `end-of-visual-line'
 
Each of these keys gets a repeatable command.  `home' and `end' move
among logical lines.  `C-a' and `C-e' move among visual lines.  Both
kinds of movement are useful in `visual-line-mode'.
 
NOTE: The attatched patch does not remove the C source code definitions
of `beginning-of-line' and `end-of-line', but that would need to be
done.  I do not have the C sources and do not want to fiddle with C.  I
assume it will be easy for someone else to remove those definitions.
(These commands do not belong in C anyway.)
 
In GNU Emacs 24.3.50.1 (i386-mingw-nt5.1.2600)
 of 2012-12-18 on MS-W7-DANI
Bzr revision: 111265 eliz@gnu.org-20121218190556-x9wmq083vwecgu0f
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.7) --no-opt --enable-checking --cflags
 -Ic:/emacs/libs/libXpm-3.5.10/include -Ic:/emacs/libs/libXpm-3.5.10/src
 -Ic:/emacs/libs/libpng-dev_1.4.3-1_win32/include
 -Ic:/emacs/libs/zlib-dev_1.2.5-2_win32/include
 -Ic:/emacs/libs/giflib-4.1.4-1-lib/include
 -Ic:/emacs/libs/jpeg-6b-4-lib/include
 -Ic:/emacs/libs/tiff-3.8.2-1-lib/include
 -Ic:/emacs/libs/libxml2-2.7.8-w32-bin/include/libxml2
 -Ic:/emacs/libs/gnutls-3.0.9-w32-bin/include
 -Ic:/emacs/libs/libiconv-1.9.2-1-lib/include'

[-- Attachment #2: simple-2012-12-24.patch --]
[-- Type: application/octet-stream, Size: 6674 bytes --]

diff -c c\:/foo/simple.el c\:/foo/simple-patched-2012-12-24.el
*** c:/foo/simple.el	Mon Dec 24 13:48:06 2012
--- c:/foo/simple-patched-2012-12-24.el	Mon Dec 24 14:13:14 2012
***************
*** 819,824 ****
--- 819,854 ----
  	 (overlay-recenter (point))
  	 (recenter -3))))
  
+ (defun end-of-line (&optional n)
+   "Move cursor to end of current line or end of next line if repeated.
+ If called interactively with no prefix arg:
+  If the previous command was also `end-of-line' then move to the
+  end of the next line.  Else move to the end of the current line.
+ Otherwise, move to the end of the Nth next line (Nth previous line
+  if N <0 )."
+   (interactive
+    (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0)))
+   (unless n (setq n  0))                ; non-interactive with no arg
+   (if (and (eq this-command last-command)  (not current-prefix-arg))
+       (forward-line 1)
+     (forward-line n))
+   (let ((inhibit-field-text-motion  t))  (end-of-line)))
+ 
+ (defun beginning-of-line (&optional n)
+   "Move cursor to beginning of current line or next line if repeated.
+ If called interactively with no prefix arg:
+  If the previous command was also `beginning-of-line' then move to the
+  beginning of the previous line.  Else move to the beginning of the
+  current line.
+ Otherwise, move to the beginning of the Nth previous line (Nth next
+  line if N < 0)."
+   (interactive
+    (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0)))
+   (unless n (setq n  0))                ; non-interactive with no arg
+   (if (and (eq this-command last-command)  (not current-prefix-arg))
+       (forward-line -1)
+     (forward-line (- n))))
+ 
  (defcustom delete-active-region t
    "Whether single-char deletion commands delete an active region.
  This has an effect only if Transient Mark mode is enabled, and
***************
*** 5007,5036 ****
  ;;; Editing based on visual lines, as opposed to logical lines.
  
  (defun end-of-visual-line (&optional n)
!   "Move point to end of current visual line.
! With argument N not nil or 1, move forward N - 1 visual lines first.
! If point reaches the beginning or end of buffer, it stops there.
! To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
!   (interactive "^p")
!   (or n (setq n 1))
!   (if (/= n 1)
!       (let ((line-move-visual t))
! 	(line-move (1- n) t)))
    ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't
    ;; constrain to field boundaries, so we don't either.
    (vertical-motion (cons (window-width) 0)))
  
  (defun beginning-of-visual-line (&optional n)
!   "Move point to beginning of current visual line.
! With argument N not nil or 1, move forward N - 1 visual lines first.
  If point reaches the beginning or end of buffer, it stops there.
! To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
!   (interactive "^p")
!   (or n (setq n 1))
!   (let ((opoint (point)))
!     (if (/= n 1)
! 	(let ((line-move-visual t))
! 	  (line-move (1- n) t)))
      (vertical-motion 0)
      ;; Constrain to field boundaries, like `move-beginning-of-line'.
      (goto-char (constrain-to-field (point) opoint (/= n 1)))))
--- 5037,5083 ----
  ;;; Editing based on visual lines, as opposed to logical lines.
  
  (defun end-of-visual-line (&optional n)
!   "Move cursor to end of current visual line, or end of next if repeated.
! If point reaches the beginning or end of buffer, stop there.
! To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
! 
! If called interactively with no prefix argument:
!  If the previous command was also `end-of-visual-line', then move to
!  the end of the next visual line.  Else move to end of current one.
! Otherwise, move to the end of the Nth next visual line (Nth previous
!  one if N < 0)."
!   (interactive
!    (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0)))
!   (unless n (setq n  0))                 ; non-interactive with no arg 
!   (let ((line-move-visual  t))
!     (if (and (eq this-command last-command)  (not current-prefix-arg))
!         (line-move 1 t)
!       (line-move n t)))
    ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't
    ;; constrain to field boundaries, so we don't either.
    (vertical-motion (cons (window-width) 0)))
  
  (defun beginning-of-visual-line (&optional n)
!   "Move cursor to beginning of current visual line or next if repeated.
  If point reaches the beginning or end of buffer, it stops there.
! To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
! 
! With argument N, move backward N visual lines.
! 
! If called interactively with no prefix argument:
!  If the previous command was also `beginning-of-visual-line', then
!  move to the beginning of the previous visual line.  Else move to the
!  beginning of the current visual line.
! Otherwise, move to the beginning of the Nth previous visual line
!  (Nth next one if N < 0)."
!   (interactive
!    (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0)))
!   (unless n (setq n  0))                 ; non-interactive with no arg
!   (let ((opoint  (point)))
!     (let ((line-move-visual  t))
!       (if (and (eq this-command last-command)  (not current-prefix-arg))
!           (line-move -1 t)
!         (line-move n t)))
      (vertical-motion 0)
      ;; Constrain to field boundaries, like `move-beginning-of-line'.
      (goto-char (constrain-to-field (point) opoint (/= n 1)))))
***************
*** 5098,5105 ****
  (defvar visual-line-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map [remap kill-line] 'kill-visual-line)
!     (define-key map [remap move-beginning-of-line] 'beginning-of-visual-line)
!     (define-key map [remap move-end-of-line]  'end-of-visual-line)
      ;; These keybindings interfere with xterm function keys.  Are
      ;; there any other suitable bindings?
      ;; (define-key map "\M-[" 'previous-logical-line)
--- 5145,5154 ----
  (defvar visual-line-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map [remap kill-line] 'kill-visual-line)
!     (define-key map [home] 'beginning-of-line)
!     (define-key map [end]  'end-of-line)
!     (define-key map "\C-a" 'beginning-of-visual-line)
!     (define-key map "\C-e" 'end-of-visual-line)
      ;; These keybindings interfere with xterm function keys.  Are
      ;; there any other suitable bindings?
      ;; (define-key map "\M-[" 'previous-logical-line)

Diff finished.  Mon Dec 24 21:13:36 2012

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-06-27 12:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-24 22:27 bug#13273: 24.3.50; [PATCH] enhancement request: repeatable `visual-line-mode' line movements Drew Adams
2012-12-25 17:41 ` Eli Zaretskii
2012-12-26  5:59   ` Drew Adams
2012-12-26  6:32   ` Drew Adams
2012-12-27 10:08     ` Vitalie Spinu
2012-12-27 16:16       ` Drew Adams
2012-12-27 19:13         ` Vitalie Spinu
2012-12-27 19:35           ` Drew Adams
2012-12-28 18:06 ` Vitalie Spinu
2012-12-28 18:51   ` Drew Adams
2012-12-28 19:22     ` Vitalie Spinu
2012-12-28 19:36       ` Eli Zaretskii
2012-12-28 19:55         ` Vitalie Spinu
2012-12-28 20:13           ` Eli Zaretskii
2012-12-28 20:04       ` Drew Adams
2012-12-28 20:33         ` Vitalie Spinu
2012-12-28 21:05           ` Drew Adams
2019-06-27 12:04 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.