all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Find the longest word in the word list file.
@ 2021-08-10 23:14 Hongyi Zhao
  2021-08-11  1:51 ` [External] : " Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-10 23:14 UTC (permalink / raw)
  To: help-gnu-emacs

I have an English word list file that stores words in a
one-word-per-line format. Now I want to find the longest word in the
word list file. For example, I can use standard UNIX tools to
accomplish this with the following simple commands:

$ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
american-english-exhaustive | \
sort -k2n | tail -1
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58

But in Emacs, what is the elisp implementation for the above task?

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



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

* RE: [External] : Find the longest word in the word list file.
  2021-08-10 23:14 Find the longest word in the word list file Hongyi Zhao
@ 2021-08-11  1:51 ` Drew Adams
  2021-08-11  3:00   ` Hongyi Zhao
  2021-08-11 13:58 ` Stephen Berman
  2021-08-11 16:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 35+ messages in thread
From: Drew Adams @ 2021-08-11  1:51 UTC (permalink / raw)
  To: Hongyi Zhao, help-gnu-emacs

> I have an English word list file that stores words in a
> one-word-per-line format. Now I want to find the longest word in the
> word list file. For example, I can use standard UNIX tools to
> accomplish this with the following simple commands:
> 
> $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> american-english-exhaustive | \
> sort -k2n | tail -1
> Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
> 
> But in Emacs, what is the elisp implementation for the above task?

I use this, from `misc-cmds.el' (https://www.emacswiki.org/emacs/download/misc-cmds.el).

I bind it to `C-<end>' in `isearch-mode-map'.  It takes you to the longest line after the cursor (repeatable).  Since you have one word per line it should do what you want.  Of course if you just want a code snippet you can dig that out of it also.

(defun goto-longest-line (beg end &optional msgp)
  "Go to the first of the longest lines in the region or buffer.
If the region is active, it is checked.
If not, the buffer (or its restriction) is checked.

Returns a list of three elements:

 (LINE LINE-LENGTH OTHER-LINES LINES-CHECKED)

LINE is the first of the longest lines measured.
LINE-LENGTH is the length of LINE.
OTHER-LINES is a list of other lines checked that are as long as LINE.
LINES-CHECKED is the number of lines measured.

Interactively, a message displays this information.

If there is only one line in the active region, then the region is
deactivated after this command, and the message mentions only LINE and
LINE-LENGTH.

If this command is repeated, it checks for the longest line after the
cursor.  That is *not* necessarily the longest line other than the
current line.  That longest line could be before or after the current
line.

To search only from the current line forward, not throughout the
buffer, you can use `C-SPC' to set the mark, then use this
\(repeatedly)."
  (interactive
   (if (or (not mark-active)  (not (< (region-beginning) (region-end))))
       (list (point-min) (point-max))
     (if (< (point) (mark))
         (list (point) (mark) 'MSGP)
       (list (mark) (point) 'MSGP))))
  (when (and (not mark-active)  (= beg end)) (error "The buffer is empty"))
  (when (and mark-active  (> (point) (mark))) (exchange-point-and-mark))
  (when (< end beg) (setq end  (prog1 beg (setq beg  end))))
  (when (eq 'goto-longest-line last-command)
    (forward-line 1) (setq beg  (point)))
  (goto-char beg)
  (when (eobp) (error "End of buffer"))
  (cond ((<= end (save-excursion (goto-char beg) (forward-line 1) (point)))
         (let ((inhibit-field-text-motion  t))  (beginning-of-line))
         (when (and (> emacs-major-version 21)  (require 'hl-line nil t))
           (let ((hl-line-mode  t))  (hl-line-highlight))
           (add-hook 'pre-command-hook #'hl-line-unhighlight nil t))
         (let ((lineno  (line-number-at-pos))
               (chars   (let ((inhibit-field-text-motion  t))
                          (save-excursion (end-of-line) (current-column)))))
           (message "Only line %d: %d chars" lineno chars)
           (let ((visible-bell  t))  (ding))
           (setq mark-active  nil)
           (list lineno chars nil 1)))
        (t
         (let* ((start-line                 (line-number-at-pos))
                (max-width                  0)
                (line                       start-line)
                (inhibit-field-text-motion  t)
                long-lines col)
           (when (eobp) (error "End of buffer"))
           (while (and (not (eobp))  (< (point) end))
             (end-of-line)
             (setq col  (current-column))
             (when (>= col max-width)
               (setq long-lines  (if (= col max-width)
                                     (cons line long-lines)
                                   (list line))
                     max-width   col))
             (forward-line 1)
             (setq line  (1+ line)))
           (setq long-lines  (nreverse long-lines))
           (let ((lines  long-lines))
             (while (and lines  (> start-line (car lines))) (pop lines))
             (goto-char (point-min))
             (when (car lines) (forward-line (1- (car lines)))))
           (when (and (> emacs-major-version 21)  (require 'hl-line nil t))
             (let ((hl-line-mode  t))  (hl-line-highlight))
             (add-hook 'pre-command-hook #'hl-line-unhighlight nil t))
           (when msgp
             (let ((others  (cdr long-lines)))
               (message "Line %d: %d chars%s (%d lines measured)"
                        (car long-lines) max-width
                        (concat
                         (and others
                              (format ", Others: {%s}" (mapconcat
                                                        (lambda (line) (format "%d" line))
                                                        (cdr long-lines) ", "))))
                        (- line start-line))))
           (list (car long-lines) max-width (cdr long-lines) (- line start-line))))))

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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  1:51 ` [External] : " Drew Adams
@ 2021-08-11  3:00   ` Hongyi Zhao
  2021-08-11  6:46     ` tomas
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-11  3:00 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

On Wed, Aug 11, 2021 at 9:51 AM Drew Adams <drew.adams@oracle.com> wrote:
>
> > I have an English word list file that stores words in a
> > one-word-per-line format. Now I want to find the longest word in the
> > word list file. For example, I can use standard UNIX tools to
> > accomplish this with the following simple commands:
> >
> > $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> > american-english-exhaustive | \
> > sort -k2n | tail -1
> > Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
> >
> > But in Emacs, what is the elisp implementation for the above task?
>
> I use this, from `misc-cmds.el' (https://www.emacswiki.org/emacs/download/misc-cmds.el).
>
> I bind it to `C-<end>' in `isearch-mode-map'.  It takes you to the longest line after the cursor (repeatable).  Since you have one word per line it should do what you want.  Of course if you just want a code snippet you can dig that out of it also.
>
> (defun goto-longest-line (beg end &optional msgp)
>   "Go to the first of the longest lines in the region or buffer.
> If the region is active, it is checked.
> If not, the buffer (or its restriction) is checked.
>
> Returns a list of three elements:
>
>  (LINE LINE-LENGTH OTHER-LINES LINES-CHECKED)
>
> LINE is the first of the longest lines measured.
> LINE-LENGTH is the length of LINE.
> OTHER-LINES is a list of other lines checked that are as long as LINE.
> LINES-CHECKED is the number of lines measured.
>
> Interactively, a message displays this information.
>
> If there is only one line in the active region, then the region is
> deactivated after this command, and the message mentions only LINE and
> LINE-LENGTH.
>
> If this command is repeated, it checks for the longest line after the
> cursor.  That is *not* necessarily the longest line other than the
> current line.  That longest line could be before or after the current
> line.
>
> To search only from the current line forward, not throughout the
> buffer, you can use `C-SPC' to set the mark, then use this
> \(repeatedly)."
>   (interactive
>    (if (or (not mark-active)  (not (< (region-beginning) (region-end))))
>        (list (point-min) (point-max))
>      (if (< (point) (mark))
>          (list (point) (mark) 'MSGP)
>        (list (mark) (point) 'MSGP))))
>   (when (and (not mark-active)  (= beg end)) (error "The buffer is empty"))
>   (when (and mark-active  (> (point) (mark))) (exchange-point-and-mark))
>   (when (< end beg) (setq end  (prog1 beg (setq beg  end))))
>   (when (eq 'goto-longest-line last-command)
>     (forward-line 1) (setq beg  (point)))
>   (goto-char beg)
>   (when (eobp) (error "End of buffer"))
>   (cond ((<= end (save-excursion (goto-char beg) (forward-line 1) (point)))
>          (let ((inhibit-field-text-motion  t))  (beginning-of-line))
>          (when (and (> emacs-major-version 21)  (require 'hl-line nil t))
>            (let ((hl-line-mode  t))  (hl-line-highlight))
>            (add-hook 'pre-command-hook #'hl-line-unhighlight nil t))
>          (let ((lineno  (line-number-at-pos))
>                (chars   (let ((inhibit-field-text-motion  t))
>                           (save-excursion (end-of-line) (current-column)))))
>            (message "Only line %d: %d chars" lineno chars)
>            (let ((visible-bell  t))  (ding))
>            (setq mark-active  nil)
>            (list lineno chars nil 1)))
>         (t
>          (let* ((start-line                 (line-number-at-pos))
>                 (max-width                  0)
>                 (line                       start-line)
>                 (inhibit-field-text-motion  t)
>                 long-lines col)
>            (when (eobp) (error "End of buffer"))
>            (while (and (not (eobp))  (< (point) end))
>              (end-of-line)
>              (setq col  (current-column))
>              (when (>= col max-width)
>                (setq long-lines  (if (= col max-width)
>                                      (cons line long-lines)
>                                    (list line))
>                      max-width   col))
>              (forward-line 1)
>              (setq line  (1+ line)))
>            (setq long-lines  (nreverse long-lines))
>            (let ((lines  long-lines))
>              (while (and lines  (> start-line (car lines))) (pop lines))
>              (goto-char (point-min))
>              (when (car lines) (forward-line (1- (car lines)))))
>            (when (and (> emacs-major-version 21)  (require 'hl-line nil t))
>              (let ((hl-line-mode  t))  (hl-line-highlight))
>              (add-hook 'pre-command-hook #'hl-line-unhighlight nil t))
>            (when msgp
>              (let ((others  (cdr long-lines)))
>                (message "Line %d: %d chars%s (%d lines measured)"
>                         (car long-lines) max-width
>                         (concat
>                          (and others
>                               (format ", Others: {%s}" (mapconcat
>                                                         (lambda (line) (format "%d" line))
>                                                         (cdr long-lines) ", "))))
>                         (- line start-line))))
>            (list (car long-lines) max-width (cdr long-lines) (- line start-line))))))

Thank you for your solution, but it seems so complicated to me.

Best regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  3:00   ` Hongyi Zhao
@ 2021-08-11  6:46     ` tomas
  2021-08-11  8:58       ` Hongyi Zhao
  2021-08-11  9:52       ` Arthur Miller
  0 siblings, 2 replies; 35+ messages in thread
From: tomas @ 2021-08-11  6:46 UTC (permalink / raw)
  To: help-gnu-emacs

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

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

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  6:46     ` tomas
@ 2021-08-11  8:58       ` Hongyi Zhao
  2021-08-11 10:03         ` tomas
  2021-08-11  9:52       ` Arthur Miller
  1 sibling, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-11  8:58 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

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.

Best, Hongyi



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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  6:46     ` tomas
  2021-08-11  8:58       ` Hongyi Zhao
@ 2021-08-11  9:52       ` Arthur Miller
  2021-08-11 10:06         ` tomas
  1 sibling, 1 reply; 35+ messages in thread
From: Arthur Miller @ 2021-08-11  9:52 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

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

<tomas@tuxteam.de> writes:

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

This looks like such a typical school assignement. Usually when students
have learned how to open and read files ...

Here is mine solution, I had same idea as Thomas, I just did it little
bit differently:

#+begin_src emacs-lisp

(defun longest-line-in-file (filename)
  (with-temp-buffer
    (insert-file-contents filename)
    (goto-char (point-min))
    (let (longest (longest-length 0) (current-length 0))
      (while (re-search-forward "^\\w.*\\w$" nil t)
        (setq current-length (- (line-end-position) (line-beginning-position)))
        (when (< longest-length current-length)
          (setq longest (cons (line-beginning-position) (line-end-position))
                longest-length current-length)))
      (buffer-substring-no-properties (car longest) (cdr longest)))))

#+end_src

Run it from M-: (longest-line-in-file "path/to/some/file") or add an
`interactive' statement if you prefer M-x. Also add some error checking,
for valid file and valid input.

It returns first occurence of the longest string in a file.

For example in a test file attached:

one
two
three
four
five
six
seven
eight
nine
ten

You will get "three" back.

If you would like the last one (eight), change the checking
condition. If you would like all of them, push them all into a list
instead of a cons cell. You could also save length with each cons cell,
as a pair of cons, or just push all three to a list, if you would like
to use it for something later on.


[-- Attachment #2: test.txt --]
[-- Type: text/plain, Size: 49 bytes --]

one
two
three
four
five
six
seven
eight
nine
ten

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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  8:58       ` Hongyi Zhao
@ 2021-08-11 10:03         ` tomas
  0 siblings, 0 replies; 35+ messages in thread
From: tomas @ 2021-08-11 10:03 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

[-- 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 --]

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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11  9:52       ` Arthur Miller
@ 2021-08-11 10:06         ` tomas
  2021-08-11 13:32           ` Hongyi Zhao
  0 siblings, 1 reply; 35+ messages in thread
From: tomas @ 2021-08-11 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

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

On Wed, Aug 11, 2021 at 11:52:58AM +0200, Arthur Miller wrote:

[...]

Always fun to see how different people go about such a thing :-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [External] : Find the longest word in the word list file.
  2021-08-11 10:06         ` tomas
@ 2021-08-11 13:32           ` Hongyi Zhao
  0 siblings, 0 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-11 13:32 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

On Wed, Aug 11, 2021 at 6:06 PM <tomas@tuxteam.de> wrote:
>
> On Wed, Aug 11, 2021 at 11:52:58AM +0200, Arthur Miller wrote:
>
> [...]
>
> Always fun to see how different people go about such a thing :-)

Awesome! Thank you and Arthur. Got the idea. And I tried the version
given by Arthur, which works like a charm. The following is the result
given by the code:

"correspond with someone about someone or something correspond with
someone about someone or something"

The above result is exactly the same as the one returned by the
following UNIX command:

$ awk '{print length($0),$0}'
Public/repo/github.com/hongyi-zhao/english-wordlist.git/american-english-exhaustive
| \
   sort -k1n | tail -1
101 correspond with someone about someone or something correspond with
someone about someone or something

Regards,
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



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

* Re: Find the longest word in the word list file.
  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 13:58 ` Stephen Berman
  2021-08-11 14:17   ` Hongyi Zhao
  2021-08-11 16:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 35+ messages in thread
From: Stephen Berman @ 2021-08-11 13:58 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

On Wed, 11 Aug 2021 07:14:05 +0800 Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> I have an English word list file that stores words in a
> one-word-per-line format. Now I want to find the longest word in the
> word list file. For example, I can use standard UNIX tools to
> accomplish this with the following simple commands:
>
> $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> american-english-exhaustive | \
> sort -k2n | tail -1
> Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
>
> But in Emacs, what is the elisp implementation for the above task?

Here's another way.  Say e.g. the following is the buffer with your list
of words:

Theory
and
Simulation
of
Materials

First do this:

(setq l
'(Theory
and
Simulation
of
Materials))

Evaluate the preceding sexp, then evaluate the following sexp:

(car (sort l (lambda (a b)
	       (> (length (symbol-name a)) (length (symbol-name b))))))
=>
Simulation

Steve Berman



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

* Re: Find the longest word in the word list file.
  2021-08-11 13:58 ` Stephen Berman
@ 2021-08-11 14:17   ` Hongyi Zhao
  2021-08-11 14:27     ` Stephen Berman
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-11 14:17 UTC (permalink / raw)
  To: Stephen Berman; +Cc: help-gnu-emacs

On Wed, Aug 11, 2021 at 9:58 PM Stephen Berman <stephen.berman@gmx.net> wrote:
>
> On Wed, 11 Aug 2021 07:14:05 +0800 Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> > I have an English word list file that stores words in a
> > one-word-per-line format. Now I want to find the longest word in the
> > word list file. For example, I can use standard UNIX tools to
> > accomplish this with the following simple commands:
> >
> > $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> > american-english-exhaustive | \
> > sort -k2n | tail -1
> > Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
> >
> > But in Emacs, what is the elisp implementation for the above task?
>
> Here's another way.  Say e.g. the following is the buffer with your list
> of words:
>
> Theory
> and
> Simulation
> of
> Materials
>
> First do this:
>
> (setq l
> '(Theory
> and
> Simulation
> of
> Materials))
>
> Evaluate the preceding sexp, then evaluate the following sexp:
>
> (car (sort l (lambda (a b)
>                (> (length (symbol-name a)) (length (symbol-name b))))))

Good. A bubble sorting, IIRC.

> =>
> Simulation
>
> Steve Berman

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  2021-08-11 14:17   ` Hongyi Zhao
@ 2021-08-11 14:27     ` Stephen Berman
  0 siblings, 0 replies; 35+ messages in thread
From: Stephen Berman @ 2021-08-11 14:27 UTC (permalink / raw)
  To: Hongyi Zhao; +Cc: help-gnu-emacs

On Wed, 11 Aug 2021 22:17:02 +0800 Hongyi Zhao <hongyi.zhao@gmail.com> wrote:

> On Wed, Aug 11, 2021 at 9:58 PM Stephen Berman <stephen.berman@gmx.net> wrote:
>>
>> On Wed, 11 Aug 2021 07:14:05 +0800 Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>>
>> > I have an English word list file that stores words in a
>> > one-word-per-line format. Now I want to find the longest word in the
>> > word list file. For example, I can use standard UNIX tools to
>> > accomplish this with the following simple commands:
>> >
>> > $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
>> > american-english-exhaustive | \
>> > sort -k2n | tail -1
>> > Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
>> >
>> > But in Emacs, what is the elisp implementation for the above task?
>>
>> Here's another way.  Say e.g. the following is the buffer with your list
>> of words:
>>
>> Theory
>> and
>> Simulation
>> of
>> Materials
>>
>> First do this:
>>
>> (setq l
>> '(Theory
>> and
>> Simulation
>> of
>> Materials))
>>
>> Evaluate the preceding sexp, then evaluate the following sexp:
>>
>> (car (sort l (lambda (a b)
>>                (> (length (symbol-name a)) (length (symbol-name b))))))
>
> Good. A bubble sorting, IIRC.

Actually, AFAIK the Emacs `sort' function implements a merge sort.

Steve Berman



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

* Re: Find the longest word in the word list file.
  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 13:58 ` 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
  2 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-11 16:09 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I have an English word list file that stores words in
> a one-word-per-line format. Now I want to find the longest
> word in the word list file. For example, I can use standard
> UNIX tools to accomplish this with the following simple
> commands:
>
> $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> american-english-exhaustive | \
> sort -k2n | tail -1
> Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58

#! /bin/zsh
longest-line () {
    local f=$1
    awk '{ print length($0) " " $0; }' $f | sort -n | tail -1
}

$ longest-line american-english-insane 
60 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch's

> But in Emacs, what is the elisp implementation for the
> above task?

This is one better suited for the shell IMO.

Hm... is that really a word?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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  2:53     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  2:10 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 12:09 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I have an English word list file that stores words in
> > a one-word-per-line format. Now I want to find the longest
> > word in the word list file. For example, I can use standard
> > UNIX tools to accomplish this with the following simple
> > commands:
> >
> > $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> > american-english-exhaustive | \
> > sort -k2n | tail -1
> > Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58
>
> #! /bin/zsh
> longest-line () {
>     local f=$1
>     awk '{ print length($0) " " $0; }' $f | sort -n | tail -1
> }
>
> $ longest-line american-english-insane
> 60 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch's
>
> > But in Emacs, what is the elisp implementation for the
> > above task?
>
> This is one better suited for the shell IMO.

I don't think so. Whether you start completely from scratch, with
elisp, there are so many selections for doing such a thing. This way
can give us a deeper understanding of algorithms and how computers
work.

> Hm... is that really a word?

No idea.

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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  2:53     ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  2:29 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

>>> But in Emacs, what is the elisp implementation for the
>>> above task?
>>
>> This is one better suited for the shell IMO.
>
> I don't think so. Whether you start completely from scratch,
> with elisp, there are so many selections for doing such
> a thing. This way can give us a deeper understanding of
> algorithms and how computers work.

Uhm, I said that with respect to solving the particular
problem, not get a deeper understanding of anything, but even
so Emacs/Elisp isn't more from scratch than awk. What makes
you think it is?

Well, maybe if you do it from the scratch buffer...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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  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
  1 sibling, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  2:53 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I don't think so. Whether you start completely from scratch,
> with elisp, there are so many selections for doing such
> a thing. This way can give us a deeper understanding of
> algorithms and how computers work.

Here you go,

(defun sort-lines-length (beg end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (list (point-min) (point-max)) ))
  (save-excursion
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (sort-subr nil
                 #'forward-line
                 #'end-of-line
                 nil nil
                 (lambda (a b) (> (- (cdr a) (car a))
                                  (- (cdr b) (car b)) ))))))
(defalias 'sll #'sort-lines-length)

https://dataswamp.org/~incal/emacs-init/sort-incal.el lines 18-32

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  3:13 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 10:29 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> >>> But in Emacs, what is the elisp implementation for the
> >>> above task?
> >>
> >> This is one better suited for the shell IMO.
> >
> > I don't think so. Whether you start completely from scratch,
> > with elisp, there are so many selections for doing such
> > a thing. This way can give us a deeper understanding of
> > algorithms and how computers work.
>
> Uhm, I said that with respect to solving the particular
> problem, not get a deeper understanding of anything, but even
> so Emacs/Elisp isn't more from scratch than awk. What makes
> you think it is?

From the point of view that lisp can be used to develop operating
systems [1], while awk absolutely can't.

> Well, maybe if you do it from the scratch buffer...

OMG. I can't say anything.

[1] https://en.wikipedia.org/wiki/Lisp_Machine_Lisp

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  3:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> From the point of view that lisp can be used to develop
> operating systems [1], while awk absolutely can't.

But awk (gawk) is written in C and so is Linux...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  3:34 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 11:18 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > From the point of view that lisp can be used to develop
> > operating systems [1], while awk absolutely can't.
>
> But awk (gawk) is written in C and so is Linux...

C is a compiled language, which makes it not as convenient as an
interpreted language for real-time interactive use. Awk, in its way,
becomes an advanced secondary packaging based on C and provides a
convenient interface for users as an interpreted (script) language,
which is exactly its purpose. Just as python, with which many
underlying processing mechanisms are hidden to normal users. Though
the similar situations also exist in lisp to some extent,  but
overall, users seem to have a lot more flexibility. Whether you are a
novice or an advanced user, you can always try to discover new
possibilities.

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  3:41 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> C is a compiled language, which makes it not as convenient
> as an interpreted language for real-time interactive use.
> Awk, in its way, becomes an advanced secondary packaging
> based on C and provides a convenient interface for users as
> an interpreted (script) language, which is exactly its
> purpose. Just as python, with which many underlying
> processing mechanisms are hidden to normal users. Though the
> similar situations also exist in lisp [...]

One of which would be that Emacs is also written in C :)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  3:52 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 11:41 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > C is a compiled language, which makes it not as convenient
> > as an interpreted language for real-time interactive use.
> > Awk, in its way, becomes an advanced secondary packaging
> > based on C and provides a convenient interface for users as
> > an interpreted (script) language, which is exactly its
> > purpose. Just as python, with which many underlying
> > processing mechanisms are hidden to normal users. Though the
> > similar situations also exist in lisp [...]
>
> One of which would be that Emacs is also written in C :)

Right. All Turing-complete languages are equivalent. But the core is
not how superior the language itself is, but how advanced, good, and
complete the ideas on which it was founded. From this point of view,
LISP is probably the most complete, superlative language, just as the
``Greenspun's tenth rule'' says [1]:

Any sufficiently complicated C or Fortran program contains an ad hoc,
informally-specified, bug-ridden, slow implementation of half of
Common Lisp.

[1] https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  4:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> ``Greenspun's tenth rule'' says [1]:
>
> Any sufficiently complicated C or Fortran program contains
> an ad hoc, informally-specified, bug-ridden, slow
> implementation of half of Common Lisp.

There are many awesome programs written in C, Quake for
example, we have already mentioned Emacs and Linux but huge
parts of the Unix tool chain is in C.

On the contrary programs written in Lisp isn't common anymore.

It is thanks to Emacs not the least that it survives and
attracts new programmers at all.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  4:25 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 12:05 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > ``Greenspun's tenth rule'' says [1]:
> >
> > Any sufficiently complicated C or Fortran program contains
> > an ad hoc, informally-specified, bug-ridden, slow
> > implementation of half of Common Lisp.
>
> There are many awesome programs written in C, Quake for
> example, we have already mentioned Emacs and Linux but huge
> parts of the Unix tool chain is in C.
>
> On the contrary programs written in Lisp isn't common anymore.
>
> It is thanks to Emacs not the least that it survives and
> attracts new programmers at all.

All in all, I think the intrinsic idea is the core. See here for the
nine ideas embodied in lisp [1].
From the ultimate point of view, any language is used to solve
practical problems, so it is the most reasonable and objective to let
the development of history as the final evaluation criterion. All
these languages are not enemies, but friends. It is because of their
cooperation that we can complete complex research and engineering
projects.

[1] http://www.paulgraham.com/diff.html

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  4:38 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> From the ultimate point of view, any language is used to
> solve practical problems, so it is the most reasonable and
> objective to let the development of history as the final
> evaluation criterion. All these languages are not enemies,
> but friends. It is because of their cooperation that we can
> complete complex research and engineering projects.

C is like the Roman Empire. Lisp is Egypt, or Greece perhaps.
Some would say Egypt was cooler and Greece more brilliant than
Rome but they both eventually became Roman provinces.
It doesn't mean their influences stopped when that happened or
that they seized to exist, right?

Or is that actually what happened?

To Lisp I mean?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  4:53 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 12:38 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> C is like the Roman Empire. Lisp is Egypt, or Greece perhaps.
> Some would say Egypt was cooler and Greece more brilliant than
> Rome but they both eventually became Roman provinces.
> It doesn't mean their influences stopped when that happened or
> that they seized to exist, right?

Right.

> Or is that actually what happened?
>
> To Lisp I mean?

Whether we realize it or not, the ultimate winner is elegant and
advanced ideas. As for what a language is called, it doesn't matter.
Emacs survived till now, it shows that its inherent advanced ideas are
not out of date, even still beyond the current concepts that have been
implemented in other languages, which makes it last forever, keep pace
with the times, self-development, and never stop.

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  5:27 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> Whether we realize it or not, the ultimate winner is elegant
> and advanced ideas. As for what a language is called, it
> doesn't matter. Emacs survived till now, it shows that its
> inherent advanced ideas are not out of date, even still
> beyond the current concepts that have been implemented in
> other languages, which makes it last forever, keep pace with
> the times, self-development, and never stop.

What about all the people who program in C but use Emacs?
Maybe they even write Elisp to automate certain stuff in their
C making process? (but not the Makefile)

I think it is a matter of styles ... some people are attracted
to a certain style. (And these people may have only that
in common.)

And: does that mean the styles are in fact very different?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 2 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  6:25 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 1:27 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> What about all the people who program in C but use Emacs?
> Maybe they even write Elisp to automate certain stuff in their
> C making process? (but not the Makefile)

I have not investigated how many of the developers of Linux kernel use
Emacs as their IDE, but it seems that Linus Torvalds uses a customized
version of Emacs [1].

[1] https://github.com/torvalds/uemacs

> I think it is a matter of styles ... some people are attracted
> to a certain style. (And these people may have only that
> in common.)
>
> And: does that mean the styles are in fact very different?

No idea.



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

* Re: Find the longest word in the word list file.
  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
  1 sibling, 0 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  6:46 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 2:25 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Thu, Aug 12, 2021 at 1:27 PM Emanuel Berg via Users list for the
> GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> > What about all the people who program in C but use Emacs?
> > Maybe they even write Elisp to automate certain stuff in their
> > C making process? (but not the Makefile)
>
> I have not investigated how many of the developers of Linux kernel use
> Emacs as their IDE, but it seems that Linus Torvalds uses a customized
> version of Emacs [1].
>
> [1] https://github.com/torvalds/uemacs

Also see here:

https://www.emacswiki.org/emacs/EditorsUsedByOthers

> > I think it is a matter of styles ... some people are attracted
> > to a certain style. (And these people may have only that
> > in common.)
> >
> > And: does that mean the styles are in fact very different?
>
> No idea.

Best regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



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

* Re: Find the longest word in the word list file.
  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
  1 sibling, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12  6:51 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I have not investigated how many of the developers of Linux
> kernel use Emacs as their IDE, but it seems that Linus
> Torvalds uses a customized version of Emacs

We all do :)

I think he uses MicroEmacs which is "Emacs-like".

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  2021-08-12  6:51                             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-12  6:59                               ` Hongyi Zhao
  0 siblings, 0 replies; 35+ messages in thread
From: Hongyi Zhao @ 2021-08-12  6:59 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Thu, Aug 12, 2021 at 2:52 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I have not investigated how many of the developers of Linux
> > kernel use Emacs as their IDE, but it seems that Linus
> > Torvalds uses a customized version of Emacs
>
> We all do :)
>
> I think he uses MicroEmacs which is "Emacs-like".

Exactly. This is a more accurate description.

Best, Hongyi



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Kevin Vigouroux via Users list for the GNU Emacs text editor @ 2021-08-12 14:47 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Hongyi Zhao wrote:
>
>> I don't think so. Whether you start completely from scratch,
>> with elisp, there are so many selections for doing such
>> a thing. This way can give us a deeper understanding of
>> algorithms and how computers work.
>
> Here you go,
>
> (defun sort-lines-length (beg end)
>   (interactive (if (use-region-p)
>                    (list (region-beginning) (region-end))
>                  (list (point-min) (point-max)) ))
>   (save-excursion
>     (save-restriction
>       (narrow-to-region beg end)
>       (goto-char (point-min))
>       (sort-subr nil
>                  #'forward-line
>                  #'end-of-line
>                  nil nil
>                  (lambda (a b) (> (- (cdr a) (car a))
>                                   (- (cdr b) (car b)) ))))))
> (defalias 'sll #'sort-lines-length)
>
> https://dataswamp.org/~incal/emacs-init/sort-incal.el lines 18-32

How do we know that the “sort key” is a cons cell?

-- 
Best regards,
Kevin Vigouroux



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12 15:45 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Vigouroux via Users list for the GNU Emacs text editor wrote:

>> Here you go,
>>
>> (defun sort-lines-length (beg end)
>>   (interactive (if (use-region-p)
>>                    (list (region-beginning) (region-end))
>>                  (list (point-min) (point-max)) ))
>>   (save-excursion
>>     (save-restriction
>>       (narrow-to-region beg end)
>>       (goto-char (point-min))
>>       (sort-subr nil
>>                  #'forward-line
>>                  #'end-of-line
>>                  nil nil
>>                  (lambda (a b) (> (- (cdr a) (car a))
>>                                   (- (cdr b) (car b)) ))))))
>> (defalias 'sll #'sort-lines-length)
>>
>> https://dataswamp.org/~incal/emacs-init/sort-incal.el lines 18-32
>
> How do we know that the “sort key” is a cons cell?

I suppose #'forward-line (NEXTRECFUN) and #'end-of-line
(ENDRECFUN) collectively define what is a record...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Kevin Vigouroux via Users list for the GNU Emacs text editor @ 2021-08-12 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Kevin Vigouroux via Users list for the GNU Emacs text editor wrote:
>
>>> Here you go,
>>>
>>> (defun sort-lines-length (beg end)
>>>   (interactive (if (use-region-p)
>>>                    (list (region-beginning) (region-end))
>>>                  (list (point-min) (point-max)) ))
>>>   (save-excursion
>>>     (save-restriction
>>>       (narrow-to-region beg end)
>>>       (goto-char (point-min))
>>>       (sort-subr nil
>>>                  #'forward-line
>>>                  #'end-of-line
>>>                  nil nil
>>>                  (lambda (a b) (> (- (cdr a) (car a))
>>>                                   (- (cdr b) (car b)) ))))))
>>> (defalias 'sll #'sort-lines-length)
>>>
>>> https://dataswamp.org/~incal/emacs-init/sort-incal.el lines 18-32
>>
>> How do we know that the “sort key” is a cons cell?
>
> I suppose #'forward-line (NEXTRECFUN) and #'end-of-line
> (ENDRECFUN) collectively define what is a record...

No, the manual only states that these functions move the point.
-- 
Best regards,
Kevin Vigouroux



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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 1 reply; 35+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-12 16:10 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Vigouroux via Users list for the GNU Emacs text editor wrote:

>> I suppose #'forward-line (NEXTRECFUN) and #'end-of-line
>> (ENDRECFUN) collectively define what is a record...
>
> No, the manual only states that these functions move
> the point.

How else do you think it happens?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Find the longest word in the word list file.
  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
  0 siblings, 0 replies; 35+ messages in thread
From: Kevin Vigouroux via Users list for the GNU Emacs text editor @ 2021-08-12 16:24 UTC (permalink / raw)
  To: help-gnu-emacs

No idea! We can look at the source code but it is a bug in the
documentation.
-- 
Best regards,
Kevin Vigouroux



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

end of thread, other threads:[~2021-08-12 16:24 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.