* Free cursor positioning.
@ 2011-08-05 8:40 Oleksandr Gavenko
2011-08-05 15:40 ` Drew Adams
2011-08-06 9:02 ` Jambunathan K
0 siblings, 2 replies; 10+ messages in thread
From: Oleksandr Gavenko @ 2011-08-05 8:40 UTC (permalink / raw)
To: help-gnu-emacs
Some user ask me how configure Emacs to move cursor in any position
like this done in editor of Far file manager.
So if you press RIGHT at the end of string cursor move right not to next
string and so on. If you type any char after the end of line
editor automatically add spaces from the end of line up to inserted new
char.
This useful for those who like rectangle command because to mark
the rectangle:
line 1 short
line 2 toooooooooooooo looooooooong
line 3 short
you need type spaces after 'short' to include tooo looong.
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Free cursor positioning.
2011-08-05 8:40 Free cursor positioning Oleksandr Gavenko
@ 2011-08-05 15:40 ` Drew Adams
2011-08-05 20:15 ` Marko Vojinovic
2011-08-06 9:02 ` Jambunathan K
1 sibling, 1 reply; 10+ messages in thread
From: Drew Adams @ 2011-08-05 15:40 UTC (permalink / raw)
To: 'Oleksandr Gavenko', help-gnu-emacs
> Some user ask me how configure Emacs to move cursor in any position
> like this done in editor of Far file manager.
>
> So if you press RIGHT at the end of string cursor move right
> not to next
> string and so on. If you type any char after the end of line
> editor automatically add spaces from the end of line up to
> inserted new
> char.
>
> This useful for those who like rectangle command because to mark
> the rectangle:
>
> line 1 short
> line 2 toooooooooooooo looooooooong
> line 3 short
>
> you need type spaces after 'short' to include tooo looong.
Sorry, I'm not sure what you're asking, or even whether you're asking a
question.
But if I had to guess I'd say you might want to take a look at picture mode. If
that's unrelated, then please ignore.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-05 15:40 ` Drew Adams
@ 2011-08-05 20:15 ` Marko Vojinovic
2011-08-05 20:25 ` Drew Adams
2011-08-05 22:47 ` Peter Münster
0 siblings, 2 replies; 10+ messages in thread
From: Marko Vojinovic @ 2011-08-05 20:15 UTC (permalink / raw)
To: help-gnu-emacs
On Friday 05 August 2011 16:40:47 Drew Adams wrote:
> > Some user ask me how configure Emacs to move cursor in any position
> > like this done in editor of Far file manager.
> >
> > So if you press RIGHT at the end of string cursor move right
> > not to next
> > string and so on. If you type any char after the end of line
> > editor automatically add spaces from the end of line up to
> > inserted new
> > char.
>
> Sorry, I'm not sure what you're asking, or even whether you're asking a
> question.
I believe that the OP wants the point (ie. cursor) to maintain the column
position when switching lines, regardless of the position of the end-of-line
character. I've seen this behavior in some editors. For example, suppose you
have the following two lines in the buffer (<eoln> is indicating end-of-line):
This is the first line of text. It is very long, but does not wrap.<eoln>
The second line is short.<eoln>
Then suppose you go with the point to the letter "p" at the end of the first
sentence (line 1, column 65), and press the down arrow to move the point to
the second line. By default the point is placed at the end of the second line
(line 2, column 25). What the OP wants is the point to be at line 2, column
65, and if he types something there, the editor should fill in the spaces
between the . and the <eoln> of the second line, to make it long enough for
the next character to be placed where the point is, at (2,65).
In other words, ignore the position of <eoln> when moving the point around,
and add spaces where ever necessary to allow for completely free cursor motion
in the buffer region. Then, when saving the file, automatically trim trailing
spaces of each line.
While I don't like this kind of behavior, it is quite common and has some
advantages, so I guess the OP is used to it. ;-) Unfortunately, I am an Emacs
beginner, and don't know how to configure it to behave this way.
HTH, :-)
Marko
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Free cursor positioning.
2011-08-05 20:15 ` Marko Vojinovic
@ 2011-08-05 20:25 ` Drew Adams
2011-08-05 23:03 ` PJ Weisberg
2011-08-05 22:47 ` Peter Münster
1 sibling, 1 reply; 10+ messages in thread
From: Drew Adams @ 2011-08-05 20:25 UTC (permalink / raw)
To: vmarko, help-gnu-emacs
> In other words, ignore the position of <eoln> when moving the
> point around, and add spaces where ever necessary to allow for
> completely free cursor motion in the buffer region. Then, when
> saving the file, automatically trim trailing spaces of each line.
Again, `M-x picture-mode'.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-05 20:15 ` Marko Vojinovic
2011-08-05 20:25 ` Drew Adams
@ 2011-08-05 22:47 ` Peter Münster
2011-08-05 22:51 ` Drew Adams
1 sibling, 1 reply; 10+ messages in thread
From: Peter Münster @ 2011-08-05 22:47 UTC (permalink / raw)
To: help-gnu-emacs
On Fri, Aug 05 2011, Marko Vojinovic wrote:
> In other words, ignore the position of <eoln> when moving the point around,
> and add spaces where ever necessary to allow for completely free cursor motion
> in the buffer region.
Perhaps picture-mode as already stated.
> Then, when saving the file, automatically trim trailing
> spaces of each line.
(add-hook 'before-save-hook 'whitespace-cleanup)
--
Peter
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Free cursor positioning.
2011-08-05 22:47 ` Peter Münster
@ 2011-08-05 22:51 ` Drew Adams
0 siblings, 0 replies; 10+ messages in thread
From: Drew Adams @ 2011-08-05 22:51 UTC (permalink / raw)
To: 'Peter "Münster"', help-gnu-emacs
> Perhaps picture-mode as already stated.
>
> > Then, when saving the file, automatically trim trailing
> > spaces of each line.
>
> (add-hook 'before-save-hook 'whitespace-cleanup)
Picture mode automatically trims trailing whitespace.
This is in fact an old Emacs cliche to remove trailing whitespace
from any buffer: `M-x picture-mode RET C-c C-c'
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-05 20:25 ` Drew Adams
@ 2011-08-05 23:03 ` PJ Weisberg
2011-08-09 4:53 ` Kevin Rodgers
0 siblings, 1 reply; 10+ messages in thread
From: PJ Weisberg @ 2011-08-05 23:03 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs, vmarko
On Fri, Aug 5, 2011 at 1:25 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> In other words, ignore the position of <eoln> when moving the
>> point around, and add spaces where ever necessary to allow for
>> completely free cursor motion in the buffer region. Then, when
>> saving the file, automatically trim trailing spaces of each line.
>
> Again, `M-x picture-mode'.
The thing is, when you're in picture mode, you're *not* in C mode,
perl mode, or whatever mode you really want to be in. He just wants a
few features of picture mode to be on all the time. Something like:
(require 'picture)
(global-set-key (kbd "<right>") 'picture-forward-column)
(global-set-key (kbd "<up>") 'picture-move-up)
(global-set-key (kbd "<down>") 'picture-move-down)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-05 8:40 Free cursor positioning Oleksandr Gavenko
2011-08-05 15:40 ` Drew Adams
@ 2011-08-06 9:02 ` Jambunathan K
1 sibling, 0 replies; 10+ messages in thread
From: Jambunathan K @ 2011-08-06 9:02 UTC (permalink / raw)
To: Oleksandr Gavenko; +Cc: help-gnu-emacs
Oleksandr Gavenko <gavenko@bifit.com.ua> writes:
> Some user ask me how configure Emacs to move cursor in any position
> like this done in editor of Far file manager.
>
> So if you press RIGHT at the end of string cursor move right not to
> next string and so on. If you type any char after the end of line
> editor automatically add spaces from the end of line up to inserted new
> char.
>
> This useful for those who like rectangle command because to mark
> the rectangle:
>
> line 1 short
> line 2 toooooooooooooo looooooooong
> line 3 short
>
> you need type spaces after 'short' to include tooo looong.
>
>
>
You can use C-u 2 3 SPC to insert space character 23 times. (For this to
work C-h k SPC should report self-insert-command)
You can also use the interactive command move-to-column to forcibly add
tabs/spaces for filling to the end of line. If you put this function in
your .emacs or temporarily install it with C-x C-e
(defun my-move-to-column (column)
(interactive "N")
(move-to-column column t))
^ C-x C-e here
then if you do
C-u 3 9 M-x my-move-to-column
anywhere from within the short line seen above it will add the needed
spaces.
ps: I am unable to see how the FORCE argument of move-to-column is
defined for interactive purposes.
Jambunathan K.
--
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-05 23:03 ` PJ Weisberg
@ 2011-08-09 4:53 ` Kevin Rodgers
2011-08-11 22:26 ` PJ Weisberg
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Rodgers @ 2011-08-09 4:53 UTC (permalink / raw)
To: help-gnu-emacs
On 8/5/11 5:03 PM, PJ Weisberg wrote:
> On Fri, Aug 5, 2011 at 1:25 PM, Drew Adams<drew.adams@oracle.com> wrote:
>>> In other words, ignore the position of<eoln> when moving the
>>> point around, and add spaces where ever necessary to allow for
>>> completely free cursor motion in the buffer region. Then, when
>>> saving the file, automatically trim trailing spaces of each line.
>>
>> Again, `M-x picture-mode'.
>
> The thing is, when you're in picture mode, you're *not* in C mode,
> perl mode, or whatever mode you really want to be in. He just wants a
> few features of picture mode to be on all the time. Something like:
>
> (require 'picture)
> (global-set-key (kbd "<right>") 'picture-forward-column)
> (global-set-key (kbd "<up>") 'picture-move-up)
> (global-set-key (kbd "<down>") 'picture-move-down)
> (add-hook 'before-save-hook 'delete-trailing-whitespace)
Wrap it in define-global-minor-mode, and/or change the global bindings and hook
to locals and wrap that in define-minor-mode.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Free cursor positioning.
2011-08-09 4:53 ` Kevin Rodgers
@ 2011-08-11 22:26 ` PJ Weisberg
0 siblings, 0 replies; 10+ messages in thread
From: PJ Weisberg @ 2011-08-11 22:26 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: Emacs-Devel devel
On Mon, Aug 8, 2011 at 9:53 PM, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote:
> On 8/5/11 5:03 PM, PJ Weisberg wrote:
>> The thing is, when you're in picture mode, you're *not* in C mode,
>> perl mode, or whatever mode you really want to be in. He just wants a
>> few features of picture mode to be on all the time. Something like:
>>
>> (require 'picture)
>> (global-set-key (kbd "<right>") 'picture-forward-column)
>> (global-set-key (kbd "<up>") 'picture-move-up)
>> (global-set-key (kbd "<down>") 'picture-move-down)
>> (add-hook 'before-save-hook 'delete-trailing-whitespace)
>
> Wrap it in define-global-minor-mode, and/or change the global bindings and
> hook
> to locals and wrap that in define-minor-mode.
The problem with that is that the keybindings don't go away when you
turn off the minor mode. And local-set-key actually affects every
buffer that uses the same keymap as the current buffer (probably every
buffer with the same major mode).
IMO, this is something that would make sense as a built-in minor mode,
something like this. (Excuse the Git patch format; I've never gotten
around to learning Bazaar.)
======================================================================
From d54542c54d1319844df3a4d9cdb1375ca6edffdc Mon Sep 17 00:00:00 2001
From: "Peter J. Weisberg" <pj@irregularexpressions.net>
Date: Thu, 11 Aug 2011 13:53:25 -0700
Subject: [PATCH] lisp/textmodes/picture.el (quarter-plane-mode): New minor
mode to use quarter-plane movement functions outside of
picture mode
---
lisp/textmodes/picture.el | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index 8148378..337ee91 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -101,7 +101,7 @@ If scan reaches end of buffer, stop there without error."
(defun picture-forward-column (arg &optional interactive)
"Move cursor right, making whitespace if necessary.
With argument, move that many columns."
- (interactive "p\nd")
+ (interactive "^p\nd")
(let (deactivate-mark)
(picture-update-desired-column interactive)
(setq picture-desired-column (max 0 (+ picture-desired-column arg)))
@@ -115,14 +115,14 @@ With argument, move that many columns."
(defun picture-backward-column (arg &optional interactive)
"Move cursor left, making whitespace if necessary.
With argument, move that many columns."
- (interactive "p\nd")
+ (interactive "^p\nd")
(picture-update-desired-column interactive)
(picture-forward-column (- arg)))
(defun picture-move-down (arg)
"Move vertically down, making whitespace if necessary.
With argument, move that many lines."
- (interactive "p")
+ (interactive "^p")
(let (deactivate-mark)
(picture-update-desired-column nil)
(picture-newline arg)
@@ -139,7 +139,7 @@ With argument, move that many lines."
(defun picture-move-up (arg)
"Move vertically up, making whitespace if necessary.
With argument, move that many lines."
- (interactive "p")
+ (interactive "^p")
(picture-update-desired-column nil)
(picture-move-down (- arg)))
@@ -786,6 +786,37 @@ Runs `picture-mode-exit-hook' at the end."
(force-mode-line-update)
(run-hooks 'picture-mode-exit-hook)))
+(defvar quarter-plane-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [remap right-char] 'picture-forward-column)
+ (define-key map [remap forward-char] 'picture-forward-column)
+ (define-key map [remap previous-line] 'picture-move-up)
+ (define-key map [remap next-line] 'picture-move-down)
+ (define-key map [remap mouse-set-point] 'picture-mouse-set-point)
+ map))
+
+;;;###autoload
+(define-minor-mode quarter-plane-mode
+ "Toggle Quarter-Plane mode on or off.
+Interactively, with no prefix argument, toggle the mode.
+With universal prefix ARG turn mode on.
+With zero or negative ARG turn mode off.
+
+Use point movement commands that act as if the text extended
+infinitely down and to the right, inserting spaces as necessary.
+Excess whitespace is trimmed when saving or exiting Quarter-Plane mode.
+\\{quarter-plane-mode-map}"
+ :lighter " Plane"
+ :group 'picture
+ :keymap quarter-plane-mode-map
+ (if quarter-plane-mode
+ (add-hook 'before-save-hook 'quarter-plane-delete-whitespace nil t)
+ (remove-hook 'before-save-hook 'quarter-plane-delete-whitespace t)))
+
+(defalias 'quarter-plane-delete-whitespace 'delete-trailing-whitespace)
+
+(add-hook 'quarter-plane-mode-off-hook 'delete-trailing-whitespace)
+
(provide 'picture)
;;; picture.el ends here
--
1.7.6.553.g917d7
-PJ
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-08-11 22:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-05 8:40 Free cursor positioning Oleksandr Gavenko
2011-08-05 15:40 ` Drew Adams
2011-08-05 20:15 ` Marko Vojinovic
2011-08-05 20:25 ` Drew Adams
2011-08-05 23:03 ` PJ Weisberg
2011-08-09 4:53 ` Kevin Rodgers
2011-08-11 22:26 ` PJ Weisberg
2011-08-05 22:47 ` Peter Münster
2011-08-05 22:51 ` Drew Adams
2011-08-06 9:02 ` Jambunathan K
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).