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

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

Re: [External] : Find the longest word in the word list file.


From: tomas
Subject: Re: [External] : Find the longest word in the word list file.
Date: Wed, 11 Aug 2021 12:03:05 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Aug 11, 2021 at 04:58:32PM +0800, Hongyi Zhao wrote:
> On Wed, Aug 11, 2021 at 2:47 PM <tomas@tuxteam.de> wrote:
> >
> > On Wed, Aug 11, 2021 at 11:00:53AM +0800, Hongyi Zhao wrote:
> > > On Wed, Aug 11, 2021 at 9:51 AM Drew Adams <drew.adams@oracle.com> wrote:
> >
> > [...]
> >
> > > Thank you for your solution, but it seems so complicated to me.
> >
> > You prefer something to hack on yourself ;-)
> >
> > OK, here's one attempt. But be careful. I just tested it
> > twice, so there may be two bugs left :-)
> >
> >   (defun goto-longest-line ()
> >     (let ((maxpos)
> >           (maxlen 0))
> >       (goto-char (point-min))
> >       (while
> >           (let ((len (- (line-end-position)
> >                         (line-beginning-position))))
> >             (when (> len maxlen)
> >               (setq maxlen len
> >                     maxpos (point)))
> >             (= (forward-line) 0)))
> >       (goto-char maxpos)))
> 
> Wonderful. How to test it with the word list file opened? I try to put
> the above code on the minibuffer of the opened word list file's frame,
> and then hit `M-:', but it doesn't work.

I put that in some buffer (say *scratch* -- but loading the file from
disk works too), execute the definition by putting point at the end
and doing C-x C-e. Then the function is defined.

After that, I go to the buffer I want to test for the longest line,
do M-x eval-expression <RET> (goto-longest-line) to call the function.

Point ends up (so one hopes :) at the buffer's longest line.

As I said, there are bugs in there, so beware :-)

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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