From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: on adding a function call to a s-exp Date: Wed, 13 Jun 2018 18:48:31 +0200 Organization: Aioe.org NNTP Server Message-ID: <86a7rytyxs.fsf@zoho.com> References: <864libzkem.fsf@gmail.com> <86zi026stt.fsf@gmail.com> <86wov55r33.fsf@gmail.com> <87o9ggdolh.fsf@telefonica.net> <53126606-4d8c-46d3-aa9f-f27879885b02@default> <87k1r33r0q.fsf@gmail.com> <51f2e6c9-0668-0aa7-c531-0b0aed47f28f@easy-emacs.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1528908506 17059 195.159.176.226 (13 Jun 2018 16:48:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2018 16:48:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 13 18:48:22 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fT8wX-0004Lj-QF for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2018 18:48:21 +0200 Original-Received: from localhost ([::1]:35689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT8yf-0003A2-1T for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jun 2018 12:50:33 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-NNTP-Posting-Host: cRcuMnzjCdtBkcQq4LWXQQ.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org Cancel-Lock: sha1:aMI/yedUZLDK8DI4E/GWGcw75+s= Mail-Copies-To: never X-Notice: Filtered by postfilter v. 0.8.3 Original-Xref: usenet.stanford.edu gnu.emacs.help:223012 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:117133 Archived-At: Távora wrote: > DWIM guessing One point regarding language: DWIM is far from the computer "guessing" what the user wants! Because the different actions are very predictable based on the current state (which is known, all clear and visible, and often part of the workflow just one second ago), the Emacs user is very aware of what is going on, and the computer response is equally predictable! Seeing the state is whatever it is, or setting it up a certain way prior to invoking the DWIM command, is thus part of executing the command in the way that fits the situation! So DWIM is a way to set up a natural, intuitive workflow with less keys to memorize - it is not the user being moronic, hitting the same key for tons of purposes, and then have the computer sweat in panic, trying to put together something sensible of it! There seems to be at least two definitions of DWIM. One is to do different things depending on if some situation is or is not there. And it can be based on something as simple as the position of the cursor. For example, in dired, if there is a file at point, kill its path; if there isn't, kill the path of the directory. As in: (defun dired-kill-path-dwim () (interactive) (kill-new (or (dired-get-filename nil t) ; kill file including path; or (dired-current-directory) ))) ; kill directory path if file u/a The other, which is more undisputably DWIM, is when you either use the region, or don't use the region because there isn't one, and instead fall back to a default behavior. For example, to count the chars, if there is a region, count the chars in the region, if there isn't one, count the chars in the whole buffer. As in: (defun count-chars (&optional start end) (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)) )) (message "%d" (- end start)) ) As you see, this is all-deterministic, no guessing, and setting the state up is part of executing the command. And that sounds complicated and cool but actually it is completely natural. -- underground experts united http://user.it.uu.se/~embe8573