From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: mykie.el Date: Fri, 03 Jan 2014 23:34:01 -0500 Message-ID: References: <87bnzshlo5.fsf@flea.lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1388810054 30903 80.91.229.3 (4 Jan 2014 04:34:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Jan 2014 04:34:14 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 04 05:34:20 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VzIwF-0007L6-W8 for ged-emacs-devel@m.gmane.org; Sat, 04 Jan 2014 05:34:20 +0100 Original-Received: from localhost ([::1]:53100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzIwF-0008Mb-Dp for ged-emacs-devel@m.gmane.org; Fri, 03 Jan 2014 23:34:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzIw5-0008G2-NE for emacs-devel@gnu.org; Fri, 03 Jan 2014 23:34:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VzIvy-0004rP-Ct for emacs-devel@gnu.org; Fri, 03 Jan 2014 23:34:09 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:29787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzIvy-0004rD-8X for emacs-devel@gnu.org; Fri, 03 Jan 2014 23:34:02 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFG4rwsm/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjWGDKQOIYZwZgV6DFQ X-IPAS-Result: Av4EABK/CFG4rwsm/2dsb2JhbABEvw4Xc4IeAQEEAVYoCws0EhQYDYhCBsEtjWGDKQOIYZwZgV6DFQ X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="43947948" Original-Received: from 184-175-11-38.dsl.teksavvy.com (HELO pastel.home) ([184.175.11.38]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 03 Jan 2014 23:34:01 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 38FCD6063D; Fri, 3 Jan 2014 23:34:01 -0500 (EST) In-Reply-To: <87bnzshlo5.fsf@flea.lifelogs.com> (Ted Zlatanov's message of "Fri, 03 Jan 2014 15:09:46 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:167254 Archived-At: > Here's an example of context-dependent usage: > (mykie:global-set-key "C-j" > :default '(progn > (delete-trailing-whitespace) > (case major-mode > (org-mode (org-return-indent)) > (t (newline-and-indent)))) > :C-u&eolp '(fill-region (point-at-bol) (point-at-eol)) > :region 'query-replace-regexp) > (many other keywords are available, e.g. :prog for activating only in > programming modes) Is that really much better than: (global-set-key "\C-j" (lambda () (interactive) (cond (current-prefix-arg (fill-region (point-at-bol) (point-at-eol))) ((and (use-region-p) (eolp)) (call-interactively 'query-replace-regexp)) (t (delete-trailing-whitespace) (case major-mode (org-mode (org-return-indent)) (t (newline-and-indent))))))) IIUC the need for "context dependent bindings" becomes more interesting when you want the different cases to be specified independently. As in (my-global-set-key "\C-j" :predicate current-prefix-arg :action (fill-region (point-at-bol) (point-at-eol))) (my-global-set-key "\C-j" :predicate (and (use-region-p) (eolp)) :action 'query-replace-regexp) I'm not sure exactly how best to do that, tho. Stefan