all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: John Wiegley <jwiegley@gmail.com>
Cc: tino.calancha@gmail.com, drew.adams@oracle.com, emacs-devel@gnu.org
Subject: Re: Ibuffer: w and B default to buffer at current line
Date: Sun, 18 Sep 2016 17:26:03 +0300	[thread overview]
Message-ID: <83r38hi8sk.fsf@gnu.org> (raw)
In-Reply-To: <m2k2eamcoy.fsf@newartisans.com> (message from John Wiegley on Sat, 17 Sep 2016 14:35:57 -0700)

> From: John Wiegley <jwiegley@gmail.com>
> Cc: drew.adams@oracle.com,  emacs-devel@gnu.org,  tino.calancha@gmail.com
> Date: Sat, 17 Sep 2016 14:35:57 -0700
> 
> > If DWIM is okay in the UI, then functions that behave in support of that UI
> > should also be okay.
> 
> Since this responses surprised me a bit, I'm going to assume that I've
> misunderstood somehow.
> 
> Let me give a hypothetical example: Assume for the sake of argument that
> `count-lines' did not report characters as well, and that someone wished to
> extend the `count-lines' command so that, given a prefix arg, it would count
> characters instead of lines.
> 
> What I think should happen in this case is that a new command be created:
> count-items-in-region, which by default counts lines, but with a prefix
> argument counts characters. This leaves that command open to many new
> behaviors in future, while `count-lines' keeps doing just what it says: count
> lines.

If we have 2 functions, one only for counting lines and another only
for counting characters, then how will we give a user a command that
can do both depending on the prefix argument?

In Emacs, every command is a function, so eventually, we would need to
have a single function which could do both, right?  Therefore, the
only issue here is whether that function should be called count-lines
or something else, right?

Now let's make one step forward, and imagine a command that decides
whether or not to count characters as well as lines based on some
context, whatever that may be, and imagine that such a command could
reliably make that decision.  We will then have a function with such a
DWIMish modus operandi, which is totally okay, and is actually the
_only_ way of having such commands in Emacs -- by writing a function
which implements that DWIM.

IOW, as long as having DWIM in a command is okay, it should also be
okay in a function, because in Emacs every command is a function.

> What I would object to is adding a new argument to `count-lines', called
> `characters-p', that changes the behavior of count-lines to now count
> characters instead (again, remember this is hypothetical, I know that today's
> `count-lines' already counts characters as well).

Then how would you implement a command which could do both, under some
circumstances?

> Just because I want DWIM from my interface, doesn't mean I need to implement
> it as DWIM in my functions.

But there are no user interfaces in Emacs except functions.  And if
you are saying that DWIM can only be present in top-level functions
that have an interactive spec, then (a) I think this is too
restrictive and will cause us to put too much code on the top level,
and (b) we cannot prevent Lisp programs from invoking commands as
functions.

> I believe -- very strongly -- that each function should do one thing
> and one thing well, and this one thing should be documented well. I
> don't like magical functions with lots of alternative behaviors,
> unless it is a command created for the purpose of magically
> dispatching to other functions based on its context of use. Such
> magical interface functions are quite alright in my book; but
> complexifying the behavior of core functions is not.

This all boils down to the definition of "core functions", I guess.
If you want to apply this rule only to core functions, you had better
came up with a very good and precise definition.  I predict that this
would be hard to do, and we will have many incidents of Lisp programs
that try to call non-core DWIM functions and requests to remove a
function from the core to make it more DWIMish.  IOW, I believe this
goal is not reachable in Emacs, not in practice anyway.



  parent reply	other threads:[~2016-09-18 14:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14  5:35 Ibuffer: w and B default to buffer at current line Tino Calancha
2016-09-14  6:41 ` John Wiegley
2016-09-14  7:21   ` Tino Calancha
2016-09-14 14:08     ` Drew Adams
2016-09-15 22:05     ` John Wiegley
2016-09-16  6:40       ` Eli Zaretskii
     [not found]       ` <<83intw5our.fsf@gnu.org>
2016-09-16 14:53         ` Drew Adams
2016-09-17 16:30           ` John Wiegley
2016-09-17 17:21             ` Eli Zaretskii
2016-09-17 21:35               ` John Wiegley
2016-09-17 23:26                 ` Drew Adams
2016-09-17 23:51                   ` John Wiegley
2016-09-18  1:45                     ` Drew Adams
2016-09-18  2:18                       ` John Wiegley
2016-09-18 14:26                 ` Eli Zaretskii [this message]
2016-09-18 19:35                   ` John Wiegley
     [not found]             ` <<83zin630i9.fsf@gnu.org>
2016-09-17 18:47               ` Drew Adams
2016-09-17 19:25                 ` Eli Zaretskii
     [not found]                 ` <<83vaxuib1p.fsf@gnu.org>
2016-09-17 19:33                   ` Drew Adams
2016-09-18 14:29                     ` Eli Zaretskii
     [not found]                   ` <<d33a60f5-b8b6-4637-b3e6-ea1b09d98f85@default>
     [not found]                     ` <<83poo1i8nf.fsf@gnu.org>
2016-09-18 17:55                       ` naming functions [was: Ibuffer: w and B default to buffer at current line] Drew Adams
2016-09-18 19:23                         ` John Wiegley
2016-09-18 23:24                           ` Drew Adams
2016-09-19 16:35                           ` Eli Zaretskii
2016-09-17 18:22   ` Ibuffer: w and B default to buffer at current line Tino Calancha
2016-09-26 12:08     ` Tino Calancha
2016-10-03 12:28       ` Tino Calancha

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=83r38hi8sk.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=jwiegley@gmail.com \
    --cc=tino.calancha@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.