all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* title function for boxquote
@ 2005-01-30 22:19 Sebastian Luque
  2005-01-31  0:49 ` Sebastian Luque
       [not found] ` <mailman.61.1107133370.2841.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Luque @ 2005-01-30 22:19 UTC (permalink / raw)


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 "]"))))

(setq boxquote-kill-ring-save-title
      'my-title-function)

What's wrong with this picture? Thanks in advance.

-- 
Best wishes,
Sebastian

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

* Re: title function for boxquote
  2005-01-30 22:19 title function for boxquote Sebastian Luque
@ 2005-01-31  0:49 ` Sebastian Luque
       [not found] ` <mailman.61.1107133370.2841.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Luque @ 2005-01-31  0:49 UTC (permalink / raw)


On Sun, 30 Jan 2005 16:19:15 -0600, Sebastian Luque <sluque@mun.ca> wrote:

[...]

> What's wrong with this picture? Thanks in advance.

Some debugging later...I got it:

,-----[ .emacs -- Lines: 277 - 288 ]
| (setq boxquote-kill-ring-save-title
|       (lambda ()
|  	(let ((from-line (count-lines (point-min) (mark)))
|  	      (to-line (count-lines (point-min) (point))))
|  	  (setq my-title
| 		(concat (buffer-name)
| 			" -- Lines: "
| 			(number-to-string from-line)
| 			" - "
| 			(number-to-string to-line)))
| 	  my-title)))
`-----

if anybody is interested.

-- 
Best wishes,
Sebastian

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

* Re: title function for boxquote
       [not found] <mailman.56.1107127949.2841.help-gnu-emacs@gnu.org>
@ 2005-01-31  9:46 ` Karl Pflästerer
  2005-01-31 14:43   ` Sebastian Luque
  0 siblings, 1 reply; 5+ messages in thread
From: Karl Pflästerer @ 2005-01-31  9:46 UTC (permalink / raw)


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

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

* Re: title function for boxquote
       [not found] ` <mailman.61.1107133370.2841.help-gnu-emacs@gnu.org>
@ 2005-01-31 11:10   ` Sébastien Kirche
  0 siblings, 0 replies; 5+ messages in thread
From: Sébastien Kirche @ 2005-01-31 11:10 UTC (permalink / raw)


Le 31 Jan 2005, Sebastian Luque a dit :

> if anybody is interested.

Nice snippet. Thank you :)

-- 
Sébastien Kirche

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

* Re: title function for boxquote
  2005-01-31  9:46 ` Karl Pflästerer
@ 2005-01-31 14:43   ` Sebastian Luque
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Luque @ 2005-01-31 14:43 UTC (permalink / raw)


On Mon, 31 Jan 2005 10:46:06 +0100, sigurd@12move.de (Karl Pflästerer) wrote:

[...]

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

Thanks for pointing those out, I should read the lisp intro again!

[...]

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

That's much more efficient than mine.


Thank you!

-- 
Best wishes,
Sebastian

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

end of thread, other threads:[~2005-01-31 14:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-30 22:19 title function for boxquote Sebastian Luque
2005-01-31  0:49 ` Sebastian Luque
     [not found] ` <mailman.61.1107133370.2841.help-gnu-emacs@gnu.org>
2005-01-31 11:10   ` Sébastien Kirche
     [not found] <mailman.56.1107127949.2841.help-gnu-emacs@gnu.org>
2005-01-31  9:46 ` Karl Pflästerer
2005-01-31 14:43   ` Sebastian Luque

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.