all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Chong Yidong" <cyd@stupidchicken.com>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: require-hard-newlines to use newline
Date: Fri, 11 Mar 2005 08:03:54 -0500 (EST)	[thread overview]
Message-ID: <3222.220.255.169.59.1110546234.squirrel@www.stupidchicken.com> (raw)
In-Reply-To: <m364zyfphr.fsf@kfs-l.imdomain.dk>

> If we agree that those hooks are the proper approach, and you can
> write the proper doc for them, this is a trivial change, so I don't
> see why we have to wait.
>
> Especially if that means that longlines.el can go into 22.1.

Okay then. How about this patch?

While writing it, I figured out that I only need to introduce one hook
(`before-kill-functions'), not two. The hook for yanking is not needed for
longlines.el -- I can handle that with post-command-hook (which longlines
already makes use of anyway.)

`before-kill-functions' seems like a convenient thing to have in any
event, since Emacs Lisp packages can use it to apply the yank-handler text
property on the fly.


*** simple.el~	Fri Mar 11 19:27:00 2005
--- simple.el	Fri Mar 11 21:00:45 2005
***************
*** 2275,2280 ****
--- 2275,2286 ----
  (defvar kill-ring-yank-pointer nil
    "The tail of the kill ring whose car is the last thing yanked.")

+ (defvar before-kill-functions nil
+   "List of functions called on the region before killing.
+ This abnormal hook is run before `kill-region' and
+ `copy-region-as-kill', with the beginning and end positions of
+ the killed region as the arguments.")
+
  (defun kill-new (string &optional replace yank-handler)
    "Make STRING the latest kill in the kill ring.
  Set `kill-ring-yank-pointer' to point to it.
***************
*** 2371,2376 ****
--- 2377,2385 ----
  The command \\[yank] can retrieve it from there.
  \(If you want to kill and then yank immediately, use \\[kill-ring-save].)

+ This runs the abnormal hook `before-kill-functions' with the
+ arguments BEG and END before actually killing.
+
  If you want to append the killed region to the last killed text,
  use \\[append-next-kill] before \\[kill-region].

***************
*** 2390,2395 ****
--- 2399,2405 ----
  specifies the yank-handler text property to be set on the killed
  text.  See `insert-for-yank'."
    (interactive "r")
+   (run-hook-with-args 'before-kill-functions beg end)
    (condition-case nil
        (let ((string (delete-and-extract-region beg end)))
  	(when string			;STRING is nil if BEG = END
***************
*** 2424,2431 ****
    "Save the region as if killed, but don't kill it.
  In Transient Mark mode, deactivate the mark.
  If `interprogram-cut-function' is non-nil, also save the text for a window
! system cut and paste."
    (interactive "r")
    (if (eq last-command 'kill-region)
        (kill-append (buffer-substring beg end) (< end beg))
      (kill-new (buffer-substring beg end)))
--- 2434,2445 ----
    "Save the region as if killed, but don't kill it.
  In Transient Mark mode, deactivate the mark.
  If `interprogram-cut-function' is non-nil, also save the text for a window
! system cut and paste.
!
! The abnormal hook `before-kill-functions' is run with the
! arguments BEG and END before the region is saved."
    (interactive "r")
+   (run-hook-with-args 'before-kill-functions beg end)
    (if (eq last-command 'kill-region)
        (kill-append (buffer-substring beg end) (< end beg))
      (kill-new (buffer-substring beg end)))

  reply	other threads:[~2005-03-11 13:03 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-02  2:26 (no subject) Chong Yidong
2005-03-02  3:02 ` Luc Teirlinck
2005-03-02  3:26   ` require-hard-newlines to use newline Chong Yidong
2005-03-02  3:55     ` Luc Teirlinck
2005-03-03  2:29     ` Richard Stallman
2005-03-03  2:49       ` Chong Yidong
2005-03-03 20:57         ` Richard Stallman
2005-03-03 22:32           ` Chong Yidong
2005-03-04  0:33             ` Luc Teirlinck
2005-03-04  0:56               ` Chong Yidong
2005-03-04  1:40                 ` Miles Bader
2005-03-04  6:02                   ` Chong Yidong
2005-03-04  9:55                     ` David Kastrup
2005-03-04 23:46                   ` Richard Stallman
2005-03-08  0:05                     ` Luc Teirlinck
2005-03-08  2:10                       ` Chong Yidong
2005-03-08  3:09                         ` Luc Teirlinck
2005-03-08  4:28                         ` Luc Teirlinck
2005-03-08 15:45                           ` Luc Teirlinck
2005-03-08 16:42                             ` Chong Yidong
2005-03-08 18:04                               ` Stefan Monnier
2005-03-08 18:12                                 ` Luc Teirlinck
2005-03-08 19:02                                   ` Stefan Monnier
2005-03-08 18:26                                 ` Luc Teirlinck
2005-03-08 16:03                       ` Richard Stallman
2005-03-08 16:39                         ` Chong Yidong
2005-03-09  9:45                           ` Chong Yidong
2005-03-11  1:46                           ` Richard Stallman
2005-03-11  9:10                             ` Chong Yidong
2005-03-11 10:25                               ` Kim F. Storm
2005-03-11 13:03                                 ` Chong Yidong [this message]
2005-03-11 14:32                                   ` Stefan Monnier
2005-03-11 14:57                                     ` Kim F. Storm
2005-03-11 15:08                                       ` Chong Yidong
2005-03-11 15:28                                         ` Stefan Monnier
2005-03-11 15:13                                       ` Chong Yidong
2005-03-11 15:30                                       ` Stefan Monnier
2005-03-11 16:11                                         ` Chong Yidong
2005-03-11 17:32                                           ` Stefan Monnier
2005-03-12  2:40                                             ` Chong Yidong
2005-03-11 22:29                                           ` Kim F. Storm
2005-03-12  2:23                                             ` Chong Yidong
2005-03-12 22:16                                   ` Richard Stallman
2005-03-12 23:53                                     ` Stefan Monnier
2005-03-14  3:00                                       ` Richard Stallman
2005-03-13  6:14                                     ` Chong Yidong
2005-03-14  3:00                                       ` Richard Stallman
2005-03-14  3:42                                         ` Chong Yidong
2005-03-15 18:39                                           ` Richard Stallman
2005-03-12 22:16                               ` Richard Stallman
2005-03-04 23:45             ` Richard Stallman
2005-03-05  2:03               ` Chong Yidong
2005-03-06  0:41                 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-03-06  2:18 Chong Yidong
2005-03-07  5:02 ` Richard Stallman
2005-03-07 10:45   ` Oliver Scholz
2005-03-08  0:50     ` Luc Teirlinck
2005-03-08  1:43       ` Luc Teirlinck
2005-03-08  2:52     ` Richard Stallman
2005-03-08  1:31   ` Luc Teirlinck

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

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

  git send-email \
    --in-reply-to=3222.220.255.169.59.1110546234.squirrel@www.stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=rms@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 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.