From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: A different way to interactively pass options to commands Date: Wed, 17 Feb 2021 15:07:39 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11433"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Clemens Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 17 21:10:44 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lCT9o-0002tL-8D for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Feb 2021 21:10:44 +0100 Original-Received: from localhost ([::1]:54532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCT9n-0006DP-AO for ged-emacs-devel@m.gmane-mx.org; Wed, 17 Feb 2021 15:10:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCT6y-0003BD-FJ for emacs-devel@gnu.org; Wed, 17 Feb 2021 15:07:49 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCT6t-00032x-3H for emacs-devel@gnu.org; Wed, 17 Feb 2021 15:07:47 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CAC178068C; Wed, 17 Feb 2021 15:07:41 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5540780052; Wed, 17 Feb 2021 15:07:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1613592460; bh=vrDflsfnQyaZbn8ma0rpxY+XIptC618Dtj6B0hjRIqk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=gxeIWM/eLWnFe7RHSu3f2b0p4iDnvLW+BD138HWELrzQ8yOXoUwVvxmDQQ3MekisG +Y+Byk8FAxUFCM2ZgEvyIRTpb+JNcKl0Cr/2kV+JG9gt1+DNY+cZuCGgbYSk+BHolT 1gawu/rzKV+cV5RZSFbTak0PffNAOnn18BDnDfPAbre2YrtuwkGIrZ3uxAqKUh65K3 1ztECPH7CLPlc+3/PQo0Qtg6yiYh5+NLHrIYa2Mfern6FkDOCseWeGRpp/AbTg10kO /fvjI4T8zEd9ZBbw3ICs3ipaLhrg1El49I+9Z5WbvZBKA3haa2iQPWkPWVB7KsTknB PJi1DwZY+C0Rw== Original-Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2135B120289; Wed, 17 Feb 2021 15:07:40 -0500 (EST) In-Reply-To: (Clemens's message of "Wed, 17 Feb 2021 20:50:02 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:265072 Archived-At: > The recent discussion around changing `interactive' made me think > about ways to improve that. Magit has shown a real nice UI approach to > pass options with its transient menus. Maybe a simpler but similar > mechanism could be added which could also be configured via > `interactive'. Any opinions on this? Yes, maybe. FWIW, there are other prefix commands than C-u. There's `C-x RET c`. In the `other-frame-window` GNU ELPA package there are such prefix commands to force the use of "other frame" or "other window" (arguably there could/should be one for "same window" as well). I personally also use the one below. Stefan (defun copy-next-command-output () "Prefix command to add the output of the next command to the `kill-ring`." (interactive) (let ((md (minibuffer-depth)) (marker (with-current-buffer "*Messages*" (point-max-marker)))) (cl-labels ((pre () (unless (> (minibuffer-depth) md) (add-hook 'post-command-hook #'post) (prepare))) (prepare () (with-current-buffer "*Messages*" (move-marker marker (point-max)))) (preserve () (unless (> (minibuffer-depth) md) (remove-hook 'post-command-hook #'post) (add-hook 'pre-command-hook #'pre))) (echo () (unless (> (minibuffer-depth) md) "[copy-output]")) (post () (if (> (minibuffer-depth) md) ;; Prepare, in case there's no pre-command-hook before ;; the next post-command-hook. E.g. in the case of ;; execute-extended-command. (prepare) (remove-hook 'pre-command-hook #'pre) (remove-hook 'post-command-hook #'post) (remove-hook 'prefix-command-preserve-state-hook #'preserve) (remove-hook 'prefix-command-echo-keystrokes-functions #'echo) (prefix-command-update) (with-current-buffer (marker-buffer marker) (when (< marker (point-max)) (kill-new (buffer-substring marker (point-max))))) (set-marker marker nil)))) (add-hook 'prefix-command-preserve-state-hook #'preserve) (add-hook 'prefix-command-echo-keystrokes-functions #'echo) ;; (message "BEFORE: prefix-arg=%S current-prefix-arg=%S" ;; prefix-arg current-prefix-arg) (prefix-command-preserve-state) ;; (message "AFTER: prefix-arg=%S current-prefix-arg=%S" ;; prefix-arg current-prefix-arg) )))