unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* kill-ring-max or other var to convert killing to deleting?
@ 2006-03-01 21:18 Drew Adams
  2006-03-03 22:46 ` Ryan Yeske
  2006-03-05  0:58 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2006-03-01 21:18 UTC (permalink / raw)


Suppose you want to delete some text, and not add it to the kill ring. For
example, suppose you want to delete a word backward. In this case, there is
no `backward-delete-word' function to correspond to `backward-kill-word'.
You could do this, which is essentially the definition of
`backward-kill-word' with "delete" substituted for "kill":

 (delete-region (point) (progn (forward-word (- arg)) (point)))

But wouldn't it be handy, generally, to be able to just convert an existing
`kill-*' function to a `delete-*' function? That is, bind some flag to
indicate that the deleted text is not to be added to the kill ring:

 (let ((kill-p nil)) (backward-kill-word arg))

At first sight, I thought perhaps binding `kill-ring-max' to 0 might do the
trick, but it seems that the killed text is always added to the kill ring.
It is only the cdr of the kill-ring that is affected by `kill-ring-max'.

How about making `kill-ring-max' = 0 have the effect of plain deletion?

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

* Re: kill-ring-max or other var to convert killing to deleting?
  2006-03-01 21:18 kill-ring-max or other var to convert killing to deleting? Drew Adams
@ 2006-03-03 22:46 ` Ryan Yeske
  2006-03-03 22:58   ` Drew Adams
  2006-03-05  0:58 ` Richard Stallman
  1 sibling, 1 reply; 4+ messages in thread
From: Ryan Yeske @ 2006-03-03 22:46 UTC (permalink / raw)
  Cc: emacs-devel

   But wouldn't it be handy, generally, to be able to just convert an existing
   `kill-*' function to a `delete-*' function? That is, bind some flag to
   indicate that the deleted text is not to be added to the kill ring:

    (let ((kill-p nil)) (backward-kill-word arg))

What about this:

(defun backward-delete-word (arg)
  (interactive "p")
  (let (kill-ring kill-ring-yank-pointer)
    (backward-kill-word arg)))

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

* RE: kill-ring-max or other var to convert killing to deleting?
  2006-03-03 22:46 ` Ryan Yeske
@ 2006-03-03 22:58   ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-03-03 22:58 UTC (permalink / raw)


       But wouldn't it be handy, generally, to be able to just 
       convert an existing `kill-*' function to a `delete-*' function?
       That is, bind some flag to indicate that the deleted text is
       not to be added to the kill ring:
    
        (let ((kill-p nil)) (backward-kill-word arg))
    
    What about this:
    
    (defun backward-delete-word (arg)
      (interactive "p")
      (let (kill-ring kill-ring-yank-pointer)
        (backward-kill-word arg)))

Wunderbar! Thank you. I should have thought of that.

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

* Re: kill-ring-max or other var to convert killing to deleting?
  2006-03-01 21:18 kill-ring-max or other var to convert killing to deleting? Drew Adams
  2006-03-03 22:46 ` Ryan Yeske
@ 2006-03-05  0:58 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2006-03-05  0:58 UTC (permalink / raw)
  Cc: emacs-devel

    You could do this, which is essentially the definition of
    `backward-kill-word' with "delete" substituted for "kill":

     (delete-region (point) (progn (forward-word (- arg)) (point)))

That is the recommended way to do it.  I think this is cleaner than
using a kill command and faking it out so it won't kill.

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

end of thread, other threads:[~2006-03-05  0:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-01 21:18 kill-ring-max or other var to convert killing to deleting? Drew Adams
2006-03-03 22:46 ` Ryan Yeske
2006-03-03 22:58   ` Drew Adams
2006-03-05  0:58 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

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

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).