From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Christophe Junke Newsgroups: gmane.emacs.bugs Subject: bug#31783: [PATCH v2] ido.el: define a special ido-fallback variable Date: Mon, 11 Jun 2018 10:23:40 +0200 Message-ID: <20180611082340.28727-1-junke.christophe@gmail.com> References: <83bmcktpef.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1528705507 20469 195.159.176.226 (11 Jun 2018 08:25:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 11 Jun 2018 08:25:07 +0000 (UTC) Cc: Christophe Junke To: 31783@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 11 10:25:03 2018 Return-path: Envelope-to: geb-bug-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 1fSI8L-0005AJ-O8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Jun 2018 10:25:01 +0200 Original-Received: from localhost ([::1]:47078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSIAS-0004eJ-Ij for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Jun 2018 04:27:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSIAL-0004cH-WA for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:27:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSIAI-00029z-Ot for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:27:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSIAI-00029r-LO for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fSIAI-0007CJ-C2 for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Christophe Junke Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Jun 2018 08:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31783 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.152870562027657 (code B ref -1); Mon, 11 Jun 2018 08:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Jun 2018 08:27:00 +0000 Original-Received: from localhost ([127.0.0.1]:42750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fSIAF-0007C0-U6 for submit@debbugs.gnu.org; Mon, 11 Jun 2018 04:27:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36897) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fSIAD-0007Bm-Nl for submit@debbugs.gnu.org; Mon, 11 Jun 2018 04:26:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSIA7-00025N-GB for submit@debbugs.gnu.org; Mon, 11 Jun 2018 04:26:52 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSIA7-00025H-Ch for submit@debbugs.gnu.org; Mon, 11 Jun 2018 04:26:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSIA5-0004bY-TI for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:26:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSIA2-000203-KP for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:26:49 -0400 Original-Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:33784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSIA2-0001z3-D9 for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2018 04:26:46 -0400 Original-Received: by mail-wr0-x234.google.com with SMTP id k16-v6so19390412wro.0 for ; Mon, 11 Jun 2018 01:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=okpsi0GId3eUDwRuDtNYkZcb8ITV4FbAWXAM0ax2PjI=; b=E78erb/KzCkyOzLJYxo3gzcQTiwKWm3KGU8x2PVDqDNBgVeHxXBATJqhLBRVZOayqO D6sgLC95kYmpCPPdeTwNi95k+7v/fI6dipvALi3BST22Af5xsibW1k0a0Fyq2DihK6Ic dGT5BqHLOLEUN/lFlVBmO4t2+IDO5vz49DoU9XcvVACF6rKyuIL1370FIJum8C/mlnEq 8LJ3+PsQccTMR1tYp5Gmd7mFrr3cdha+O+LXzp8H1hjx5Ygvu+O90V1DzCh/7YnJVIPj 4YhoGUwoxO/ELByWGa2Tt7FCAe0foA/9vALGiGBkKYKUTJZcZeIY5PA4F67BXe6VqRKQ 4jyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=okpsi0GId3eUDwRuDtNYkZcb8ITV4FbAWXAM0ax2PjI=; b=orxzwSYRvJEpIrl0dxPJ3Ot8F1BZG4pZRWOFWzmTgxmghRPK/hWppkb/mwB3pqVmcW g79XxownKh1qEZ5r/AdI4ZmSsN8CVSCBy3lFRcLQY6jF0Mv/mAqA+j5oyrC/jzD9Rdmq AG4RX3WBKUG/yWRYmqyYqylcGBjZPSZaWs4qnIso9dv6DFRYVuH42tMhDD7Tq08ZJyMr 51J9sgbsjuCg9ZUhUXsNOjRC5OLyKQUOKzEx5eOYu/yLUM8TfAaLF5+QQuy6pYVZEidm 1tKFODCa/KnBiDIsuKfoOyfi9Z0vmUL+kJpcvkg1LOQhq7JGS12ZelzOGy9yfZpuinI6 91bw== X-Gm-Message-State: APt69E1pJIU6zjpFTWdbXvAuoriFM7jdS1ZBB65XiUjDO4Sjf1noTkD1 3+BrfEmV2hpDZE1jS+AlobI9yJpg X-Google-Smtp-Source: ADUXVKIQ8e8vEL1EKVAqqQMFKVey0lof3xBvZOtOdPHFIE+Ck6trkkEwbhGFIZP/2AwwQKwJHAnlZw== X-Received: by 2002:adf:91e5:: with SMTP id 92-v6mr12189717wri.124.1528705604950; Mon, 11 Jun 2018 01:26:44 -0700 (PDT) Original-Received: from PAD2018L060.Parrot.Biz (smtp.parrot.biz. [62.23.167.188]) by smtp.gmail.com with ESMTPSA id q17-v6sm34623403wrs.5.2018.06.11.01.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 01:26:44 -0700 (PDT) X-Mailer: git-send-email 2.14.1 In-Reply-To: <83bmcktpef.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147278 Archived-At: - Introduce a global, special ido-fallback variable - Rename existing occurrences of fallback to ido-fallback This allows to retain the behaviour that was available prior to introducing per-file lexical-scope, namely that other modules could change what fallback command to call when ido-exit is set to 'fallback. --- Hi, I agree that it is simpler to rename the existing variable, and just add a defvar declaration. Here is a different version of the patch which does only this. Thank you for your review and your time. lisp/ido.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lisp/ido.el b/lisp/ido.el index 705e7dd630..358e856d4a 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1242,6 +1242,9 @@ Only used if `ido-use-virtual-buffers' is non-nil.") ;; Dynamically bound in ido-read-internal. (defvar ido-completing-read) +;; Indicates which fallback command to call when ido-exit is 'fallback. +(defvar ido-fallback nil) + ;;; FUNCTIONS (defun ido-active (&optional merge) @@ -2213,13 +2216,13 @@ If cursor is not at the end of the user input, move to end of input." (exit-minibuffer))) ;;; MAIN FUNCTIONS -(defun ido-buffer-internal (method &optional fallback prompt default initial switch-cmd) +(defun ido-buffer-internal (method &optional ido-fallback prompt default initial switch-cmd) ;; Internal function for ido-switch-buffer and friends (if (not ido-mode) (progn (run-hook-with-args 'ido-before-fallback-functions - (or fallback 'switch-to-buffer)) - (call-interactively (or fallback 'switch-to-buffer))) + (or ido-fallback 'switch-to-buffer)) + (call-interactively (or ido-fallback 'switch-to-buffer))) (let* ((ido-context-switch-command switch-cmd) (ido-current-directory nil) (ido-directory-nonreadable nil) @@ -2245,7 +2248,7 @@ If cursor is not at the end of the user input, move to end of input." ((eq ido-exit 'fallback) (let ((read-buffer-function nil)) - (setq this-command (or fallback 'switch-to-buffer)) + (setq this-command (or ido-fallback 'switch-to-buffer)) (run-hook-with-args 'ido-before-fallback-functions this-command) (call-interactively this-command))) @@ -2337,7 +2340,7 @@ If cursor is not at the end of the user input, move to end of input." ;; Add final slash to result in case it was missing from DEFAULT-DIRECTORY. (ido-final-slash (expand-file-name (or dir default-directory)) t)) -(defun ido-file-internal (method &optional fallback default prompt item initial switch-cmd) +(defun ido-file-internal (method &optional ido-fallback default prompt item initial switch-cmd) ;; Internal function for ido-find-file and friends (unless item (setq item 'file)) @@ -2412,7 +2415,7 @@ If cursor is not at the end of the user input, move to end of input." ;; we don't want to change directory of current buffer. (let ((default-directory ido-current-directory) (read-file-name-function nil)) - (setq this-command (or fallback 'find-file)) + (setq this-command (or ido-fallback 'find-file)) (run-hook-with-args 'ido-before-fallback-functions this-command) (call-interactively this-command))) @@ -2496,10 +2499,10 @@ If cursor is not at the end of the user input, move to end of input." ((eq method 'read-only) (ido-record-work-file filename) (setq filename (concat ido-current-directory filename)) - (ido-record-command fallback filename) + (ido-record-command ido-fallback filename) (ido-record-work-directory) - (run-hook-with-args 'ido-before-fallback-functions fallback) - (funcall fallback filename)) + (run-hook-with-args 'ido-before-fallback-functions ido-fallback) + (funcall ido-fallback filename)) ((eq method 'insert) (ido-record-work-file filename) -- 2.14.1