all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Copy rectangle - strange side effect
@ 2012-10-25 15:48 2rb1
  2012-10-25 20:34 ` Peter Dyballa
  0 siblings, 1 reply; 4+ messages in thread
From: 2rb1 @ 2012-10-25 15:48 UTC (permalink / raw)
  To: Help-gnu-emacs

Hi,

I use the emacs kill/yank rectangle function a lot.  Often I only need to
copy something.  kill+undo will of course do that; but involves quite some
keystrokes.

Thus, I tried to bind this to a key.  I have not really used Lisp since many
years ago at the University; but with the help from various sites and some
describe function look-ups I ended up with this arrangement:



(Just using kill and undo did not work).   Seems to work; but once I use
this command my kill-rectangle command does not work as required (deletes a
little text to the right of the end instead of the rectangle).  I have bound
that one as follows:



As stated above I am not experienced with Lisp nor the internal workings of
Emacs - what did I miss?  Using "<Ctrl>+x r k" still works as it used to!

/2rb1




--
View this message in context: http://emacs.1067599.n5.nabble.com/Copy-rectangle-strange-side-effect-tp268053.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



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

* Re: Copy rectangle - strange side effect
  2012-10-25 15:48 Copy rectangle - strange side effect 2rb1
@ 2012-10-25 20:34 ` Peter Dyballa
  2012-10-25 22:24   ` 2rb1
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Dyballa @ 2012-10-25 20:34 UTC (permalink / raw)
  To: 2rb1; +Cc: Help-gnu-emacs


Am 25.10.2012 um 17:48 schrieb 2rb1:

> As stated above I am not experienced with Lisp nor the internal workings of
> Emacs - what did I miss?

Not showing us your Elisp code.

Are you aware of C-x r r, copy-rectangle-to-register?

--
Greetings

  Pete

"Debugging? Klingons do not debug. Our software does not coddle the weak."




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

* Re: Copy rectangle - strange side effect
  2012-10-25 20:34 ` Peter Dyballa
@ 2012-10-25 22:24   ` 2rb1
  2012-10-26 11:31     ` 2rb1
  0 siblings, 1 reply; 4+ messages in thread
From: 2rb1 @ 2012-10-25 22:24 UTC (permalink / raw)
  To: Help-gnu-emacs

Thank you for the reply


Peter Dyballa wrote
> Not showing us your Elisp code.
> 
> Are you aware of C-x r r, copy-rectangle-to-register?
> 
> --
> Greetings
> 
>   Pete
> 
> "Debugging? Klingons do not debug. Our software does not coddle the weak."


The code is in the first post; but perhaps the  tag does not translate well
to mails (new to the forum as well...).  Anyway, here it is in plain ASCII:

(defun my-copy-rectangle ()
  "Copy rectangle as kill: Make a copy of rectangle as defined by region and
put into kill ring"
  (interactive)
  (setq my-start (region-beginning))
  (setq my-end (region-end))
  (kill-rectangle my-start my-end)
  (goto-char my-start)
  (yank-rectangle)
  )

(global-set-key [S-M-insert] 'my-copy-rectangle)       ; <Ctrl>+<Alt>+<Ins>
Copy R

(global-set-key [M-delete]  'kill-rectangle)           ; <Alt>+<Del>    Cut
R

I was not aware of the copy-rectangle-to-register; but having to also type
in a register name when I paste will probably not save me any key strokes. 
Or do you suggest to use it to bind it to a key with using a the same
register for the corresponding yank/paste option?  I will try that tomorrow.

/2rb1





--
View this message in context: http://emacs.1067599.n5.nabble.com/Copy-rectangle-strange-side-effect-tp268053p268100.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



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

* Re: Copy rectangle - strange side effect
  2012-10-25 22:24   ` 2rb1
@ 2012-10-26 11:31     ` 2rb1
  0 siblings, 0 replies; 4+ messages in thread
From: 2rb1 @ 2012-10-26 11:31 UTC (permalink / raw)
  To: Help-gnu-emacs

So I tried the copy-rectangle-to-register approach as follows:

(global-set-key [M-insert] (lambda () (interactive) (insert-register t ))) 
(global-set-key [S-M-insert] (lambda () (interactive)
(copy-rectangle-to-register t (region-beginning) (region-end) )) )

Seemed to work.  Now, I would like also to be able to have a
delete-rectangle-to-register functionality, so I came up with this:

(defun my-delete-rectangle-to-register ()
  "Copy rectangle : Make a copy of rectangle as defined by region and put
into reg"
  (interactive)
  (setq my-start (region-beginning))
  (setq my-end (region-end))
  (copy-rectangle-to-register t my-start my-end)
  (delete-rectangle my-start my-end )
  )

(global-set-key [M-delete]  'my-delete-rectangle-to-register )

At first (in the Lisp buffer) this seemed to work as expected.  This was
also true in Tcl mode; but in VHDL mode the last function would only delete
a few characters following region-end.  Unfortunately, this is where I need
these functions the most.

So I guess this is somehow related to the VHDL mode.  Why this is the case
when the functions seems to work flawlessly when invoked manually beats me. 
But then, I have to admit I am not familiar with the internal details of
Emacs - I am just a (mostly) happy user :-)

Any ideas?

/2rb1



--
View this message in context: http://emacs.1067599.n5.nabble.com/Copy-rectangle-strange-side-effect-tp268053p268134.html
Sent from the Emacs - Help mailing list archive at Nabble.com.



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

end of thread, other threads:[~2012-10-26 11:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-25 15:48 Copy rectangle - strange side effect 2rb1
2012-10-25 20:34 ` Peter Dyballa
2012-10-25 22:24   ` 2rb1
2012-10-26 11:31     ` 2rb1

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.