emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: require-hard-newlines to use newline


From: Chong Yidong
Subject: Re: require-hard-newlines to use newline
Date: Fri, 11 Mar 2005 08:03:54 -0500 (EST)
User-agent: SquirrelMail/1.4.4

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]