unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Enhance word-based commands?
Date: 19 Jan 2003 03:18:16 +0100	[thread overview]
Message-ID: <5xn0lxzxuf.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <5xr8bbyja1.fsf@kfs2.cua.dk>

storm@cua.dk (Kim F. Storm) writes:

> The fun thing about my "yank-function" functionality is that using
> dynaword-kill-word can (silently) arrange for C-y to insert the killed
> word(s) in a certain "non-trivial" way.

I renamed it to "yank-handler" (see NEWS), but here is a replacement
to kill-rectangle which allows you to insert the rectangle using C-y
(from the kill-ring), and even use M-y to cycle the kill-ring with
rectangles on the ring:

(defun kill-rectangle (start end &optional fill)
  (interactive "*r\nP")
  (when buffer-read-only
    (setq killed-rectangle (extract-rectangle start end))
    (barf-if-buffer-read-only))
  (setq killed-rectangle (delete-extract-rectangle start end fill))
  (kill-new "=" nil 
	    (list 'insert-rectangle killed-rectangle t
		  (lambda (s e)
		    (delete-rectangle s e)
		    (goto-char s)))))


It is not perfect though.  If inserting the rectangle changes tabs to
spaces, M-y may not completely restore the buffer to the state before
the rectangle was inserted, before inserting the next element from the
kill-ring.  But it's close, so I hope you can see the potential in the
new functionality.

Now, this should allow a new intelligent i-kill-word function to
install a yank-handler which will correctly insert the killed words
with appropriate spaces according to context [i.e. don't insert a
space before punctuation or at beginning/end of line].

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2003-01-19  2:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-15 19:16 Enhance word-based commands? Kai Großjohann
2003-01-16  7:42 ` Kai Großjohann
2003-01-16 23:54 ` Kim F. Storm
2003-01-17 11:48   ` Kai Großjohann
2003-01-17 15:31     ` Andreas Schwab
2003-01-17  2:56 ` Miles Bader
2003-01-17 11:45   ` Kai Großjohann
2003-01-17  9:22 ` Richard Stallman
2003-01-17 11:44   ` Kai Großjohann
2003-01-17 13:53     ` Kim F. Storm
2003-01-19  2:18       ` Kim F. Storm [this message]
2003-01-19  1:35     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xn0lxzxuf.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).