help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: title function for boxquote


From: Karl Pflästerer
Subject: Re: title function for boxquote
Date: Mon, 31 Jan 2005 10:46:06 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Hamster/2.0.6.0

On 30 Jan 2005, sluque@mun.ca wrote:

> This should be simple, but I'm flailing badly here. I'm trying to put a title
> to a boxquote that has been yanked from a region killed with
> boxquote-kill-ring-save. Something that looks like:
>
> file name [Lines: such -- such]
>
> So I came up with this, but it doesn't work:
>
> (defun my-title-function (from to)
>    "Provide a phrase for boxquote-kill-ring-save-title."
>    (interactive "r")
>    (save-restriction
>      (widen)
>      (let ((first-line (count-lines (point-min) (from)))
                                                  ^^^^^^
>         (last-line (count-lines (point-min) (to))))
                                              ^^^^
>      (concat buffer-name "[Lines: " first-line " -- " last-line "]"))))
               ^^^^^^^^^^

`from' and `to' are variables but you used them like functions.  
Furthermore you write it as an interactive function but that function
should get called from `boxquote-kill-ring-save'; on the other hand
`buffer-name' is a function not a variable.

So it could be like that:

(defun my-title-function ()
  (save-restriction
    (widen)
    (format "%s [Lines: %s --- %s]" 
            (buffer-name)
            (line-number-at-pos (region-beginning))
            (line-number-at-pos (region-end)))))

Or you forget about the name and write:

(setq boxquote-kill-ring-save-title
        (lambda ()
          (save-restriction
            (widen)
            (format "%s [Lines: %s --- %s]" 
                    (buffer-name)
                    (line-number-at-pos (region-beginning))
                    (line-number-at-pos (region-end))))))



   KP

reply via email to

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