* About `current-kill'
@ 2013-03-17 22:32 Xue Fuqiao
2013-03-18 0:00 ` Óscar Fuentes
2013-03-18 0:38 ` Stephen Berman
0 siblings, 2 replies; 4+ messages in thread
From: Xue Fuqiao @ 2013-03-17 22:32 UTC (permalink / raw)
To: help-gnu-emacs
In the definition of the function `current-kill':
[...]
(let ((ARGth-kill-element
(nthcdr (mod (- n (length kill-ring-yank-pointer))
(length kill-ring))
kill-ring)))
[...]
I understand what `ARGth-kill-element' does (from its name). But how
does it work? I cannot understand it.
--
Xue Fuqiao
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `current-kill'
2013-03-17 22:32 About `current-kill' Xue Fuqiao
@ 2013-03-18 0:00 ` Óscar Fuentes
2013-03-18 0:38 ` Stephen Berman
1 sibling, 0 replies; 4+ messages in thread
From: Óscar Fuentes @ 2013-03-18 0:00 UTC (permalink / raw)
To: help-gnu-emacs
Xue Fuqiao <xfq.free@gmail.com> writes:
> In the definition of the function `current-kill':
>
> [...]
> (let ((ARGth-kill-element
> (nthcdr (mod (- n (length kill-ring-yank-pointer))
> (length kill-ring))
> kill-ring)))
> [...]
>
> I understand what `ARGth-kill-element' does (from its name). But how
> does it work? I cannot understand it.
ARGth-kill-element *does* nothing. It *is* a variable that takes the
value of the expression that begins with (nthcdr ...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `current-kill'
2013-03-17 22:32 About `current-kill' Xue Fuqiao
2013-03-18 0:00 ` Óscar Fuentes
@ 2013-03-18 0:38 ` Stephen Berman
2013-03-18 8:24 ` Xue Fuqiao
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Berman @ 2013-03-18 0:38 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 18 Mar 2013 06:32:42 +0800 Xue Fuqiao <xfq.free@gmail.com> wrote:
> In the definition of the function `current-kill':
>
> [...]
> (let ((ARGth-kill-element
> (nthcdr (mod (- n (length kill-ring-yank-pointer))
> (length kill-ring))
> kill-ring)))
> [...]
>
> I understand what `ARGth-kill-element' does (from its name). But how
> does it work? I cannot understand it.
The kill-ring is a list of buffer substrings. As a ring, you can cycle
through it, e.g. if its length is 5, taking its cdr 8 times returns the
same result as taking its cdr 3 times; that's what the mod function
guarantees. So nthcdr skips over the first n elements of the kill-ring,
and the car of the resulting list becomes the current-kill.
Steve Berman
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About `current-kill'
2013-03-18 0:38 ` Stephen Berman
@ 2013-03-18 8:24 ` Xue Fuqiao
0 siblings, 0 replies; 4+ messages in thread
From: Xue Fuqiao @ 2013-03-18 8:24 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 18 Mar 2013 01:38:24 +0100
Stephen Berman <stephen.berman@gmx.net> wrote:
> > In the definition of the function `current-kill':
[...]
> > (let ((ARGth-kill-element
> > (nthcdr (mod (- n (length kill-ring-yank-pointer))
> > (length kill-ring))
> > kill-ring)))
[...]
> > I understand what `ARGth-kill-element' does (from its name). But how
> > does it work? I cannot understand it.
> The kill-ring is a list of buffer substrings. As a ring, you can cycle
> through it
That's what I've forgotten, thanks. It will be good if the {mark,kill}
ring uses ring.el, I think.
> e.g. if its length is 5, taking its cdr 8 times returns the
> same result as taking its cdr 3 times; that's what the mod function
> guarantees. So nthcdr skips over the first n elements of the kill-ring,
> and the car of the resulting list becomes the current-kill.
That's true, and `(mod -3 5)' evaluates 2. It suits this feature exactly.
--
Xue Fuqiao
http://www.gnu.org/software/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-18 8:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-17 22:32 About `current-kill' Xue Fuqiao
2013-03-18 0:00 ` Óscar Fuentes
2013-03-18 0:38 ` Stephen Berman
2013-03-18 8:24 ` Xue Fuqiao
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.