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

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

Re: Too fine design granularity leads to numerous macro/function/command


From: Emanuel Berg
Subject: Re: Too fine design granularity leads to numerous macro/function/command existed in Emacs.
Date: Sat, 14 Aug 2021 04:18:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hongyi Zhao wrote:

> Another reason I prefer UNIX toolchains is that they have
> been tried and tested by many people for many years, and
> using your own temporary code may expose you to greater risk
> of errors.

Yes maybe but why do it if the toolchain already does it?

OTOH if you do it why do it if it doesn't work?

So one must assume it works, if the programs don't work
somewhere it doesn't matter what you say or what discussion
that's always gonna be a problem.

> Though I have to bear some performance losses, but compared
> with today's fast computers, this is insignificant in many
> test scenarios.

Yes, but here it was quite a big difference and you can also
se on the command that it is actually better, if you have
measured advantage and observed/theoretical than that means
the better one is ... better!

But we can save the day and my function by finding a new use
case for it - see below...

# thanks to gmane.emacs.help
longest-line () {
    local f=$1
    awk 'length > max_length { max_length = length; longest_line = $0 } END { 
print longest_line }' $f
}

longest-lines () {
    local f=$1
    local lines=${2:-10}
    awk '{ print length($0) " " $0; }' $f | sort -n -r | head -n $lines
}

$ longest-lines /usr/share/dict/american-english-insane 5
60 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch's
58 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch
45 pneumonoultramicroscopicsilicovolcanoconiosis
45 pneumonoultramicroscopicsilicovolcanoconioses
34 supercalifragilisticexpialidocious

https://dataswamp.org/~incal/conf/.zsh/text
https://dataswamp.org/~incal/emacs-init/sort-incal.el

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




reply via email to

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