unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Major and minor modes
Date: Wed, 14 Jun 2017 11:36:36 +0200	[thread overview]
Message-ID: <867f0e6hcr.fsf@zoho.com> (raw)
In-Reply-To: 86bmpq6hvw.fsf@zoho.com

Another thing to note is that the major mode is
just a tool, a good tool, but not a necessary
tool for every lite code snippet.

Here (last) is an example. It is a zsh wrapper
to some awk code that I found on the net.
Of course, that made the need for awk-mode even
smaller. But I did edit the awk, in the
Shell-script[zsh] mode, without even thinking
about not being in awk-mode.

And that is actually a good rule of thumb.
When you experience not being in the right mode
is a disadvantage to your work, then you should
think of a way to factor out the foreign code.

numbers () {
    # thank you: https://unix.stackexchange.com/a/13779
    echo "items\tsum\tlow\thigh\tmedian\tmean"
    sort -n | awk '
          BEGIN {
            c = 0;
            sum = 0;
          }
          $1 ~ /^[0-9]*(\.[0-9]*)?$/ {
            a[c++] = $1;
            sum += $1;
          }
          END {
            ave = int(sum/c) + 1;
            if ( (c % 2) == 1 ) {
              median = a[ int(c/2) ];
            } else {
              median = ( a[c/2] + a[c/2-1] ) / 2;
            }
            OFS="\t";
            print c, sum, a[0], a[c-1], median, ave
          }
        '
}

-- 
underground experts united
http://user.it.uu.se/~embe8573




  reply	other threads:[~2017-06-14  9:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 23:58 Major and minor modes M.R.P.
2017-06-14  0:43 ` Jean-Christophe Helary
2017-06-14  1:49   ` Drew Adams
2017-06-14  3:49     ` Jean-Christophe Helary
2017-06-14  3:59       ` Emanuel Berg
2017-06-15  4:58         ` Marcin Borkowski
2017-06-14 14:23       ` Eli Zaretskii
2017-06-14 21:58         ` Jean-Christophe Helary
2017-06-14 23:10           ` Jean-Christophe Helary
2017-06-15 13:33             ` Emanuel Berg
2017-06-15 15:05           ` Eli Zaretskii
2017-06-15 15:16             ` Drew Adams
2017-06-16  2:09               ` Jean-Christophe Helary
2017-06-16  3:07                 ` Drew Adams
2017-06-16  4:44                   ` Emanuel Berg
2017-06-16  5:13                     ` Jean-Christophe Helary
2017-06-16  5:26                       ` Emanuel Berg
2017-06-16  6:59                   ` Eli Zaretskii
2017-06-16  8:02                     ` Jean-Christophe Helary
2017-06-16  4:34                 ` Emanuel Berg
2017-06-14  4:05     ` Emanuel Berg
2017-06-17 14:08       ` Narendra Joshi
2017-06-19  4:43         ` Krishnakant
2017-06-14  6:21     ` Krishnakant
2017-06-14  7:37     ` Phillip Lord
2017-06-14  1:54 ` Emanuel Berg
2017-06-14  7:40   ` Héctor Lahoz
2017-06-14  8:19     ` Emanuel Berg
2017-06-14  8:51       ` tomas
2017-06-14  9:25         ` Emanuel Berg
2017-06-14  9:36           ` Emanuel Berg [this message]
2017-06-14  9:58           ` tomas
2017-06-14 10:43             ` Emanuel Berg
2017-06-14 11:39             ` Emanuel Berg
2017-06-14 11:48               ` Emanuel Berg
2017-06-14 12:19               ` tomas
2017-06-14 14:15 ` Barry Margolin

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=867f0e6hcr.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).