all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: tomas@tuxteam.de
To: Hongyi Zhao <hongyi.zhao@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: [External] : Find the longest word in the word list file.
Date: Wed, 11 Aug 2021 12:03:05 +0200	[thread overview]
Message-ID: <20210811100305.GC21436@tuxteam.de> (raw)
In-Reply-To: <CAGP6PO+TsjYDszceX1VRO_aXjBLzSjX8mZ=+ajBey7v_beaBSQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1638 bytes --]

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2021-08-11 10:03 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 23:14 Find the longest word in the word list file Hongyi Zhao
2021-08-11  1:51 ` [External] : " Drew Adams
2021-08-11  3:00   ` Hongyi Zhao
2021-08-11  6:46     ` tomas
2021-08-11  8:58       ` Hongyi Zhao
2021-08-11 10:03         ` tomas [this message]
2021-08-11  9:52       ` Arthur Miller
2021-08-11 10:06         ` tomas
2021-08-11 13:32           ` Hongyi Zhao
2021-08-11 13:58 ` Stephen Berman
2021-08-11 14:17   ` Hongyi Zhao
2021-08-11 14:27     ` Stephen Berman
2021-08-11 16:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  2:10   ` Hongyi Zhao
2021-08-12  2:29     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:13       ` Hongyi Zhao
2021-08-12  3:17         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:34           ` Hongyi Zhao
2021-08-12  3:41             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  3:52               ` Hongyi Zhao
2021-08-12  4:05                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  4:25                   ` Hongyi Zhao
2021-08-12  4:38                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  4:53                       ` Hongyi Zhao
2021-08-12  5:27                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  6:25                           ` Hongyi Zhao
2021-08-12  6:46                             ` Hongyi Zhao
2021-08-12  6:51                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12  6:59                               ` Hongyi Zhao
2021-08-12  2:53     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 14:47       ` Kevin Vigouroux via Users list for the GNU Emacs text editor
2021-08-12 15:45         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 15:53           ` Kevin Vigouroux via Users list for the GNU Emacs text editor
2021-08-12 16:10             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-12 16:24               ` Kevin Vigouroux via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210811100305.GC21436@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=hongyi.zhao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.