On Wed, Aug 11, 2021 at 04:58:32PM +0800, Hongyi Zhao wrote: > On Wed, Aug 11, 2021 at 2:47 PM 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 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 (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