From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: master 695f679: Remove ; ; ; ###tramp-autoload cookie from Tramp defcustoms (Bug#47063) Date: Fri, 26 Mar 2021 15:57:01 +0000 Message-ID: <877dltaoxe.fsf@tcd.ie> References: <20210313133546.6042.78482@vcs0.savannah.gnu.org> <20210313133547.AA06C20B2E@vcs0.savannah.gnu.org> <877dma1yfv.fsf@tcd.ie> <87sg4ygmd9.fsf@gmx.de> <87zgz5uc0k.fsf@tcd.ie> <87tup0kxeg.fsf@tcd.ie> <878s6ba96u.fsf@gnus.org> <87k0pu887d.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33115"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Michael Albinus , Stefan Monnier , emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 26 16:58:15 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 1lPoqk-0008WS-Ou for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Mar 2021 16:58:14 +0100 Original-Received: from localhost ([::1]:49250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPoqj-00058i-Jp for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Mar 2021 11:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPopi-0003vl-Sv for emacs-devel@gnu.org; Fri, 26 Mar 2021 11:57:10 -0400 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:44625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPope-0006Pe-Th for emacs-devel@gnu.org; Fri, 26 Mar 2021 11:57:10 -0400 Original-Received: by mail-wr1-x431.google.com with SMTP id c8so6100711wrq.11 for ; Fri, 26 Mar 2021 08:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=hJ6xjd0cZYqKXWWAgCQRWdeyZLNHCyKCwiTEIxClln8=; b=PalgUe7ZsgE353PJLZ3c1LIVrDxCYqt0qtvDKlGKrsO+IyoCvR2PhbToYtVD4bIWkB xIMmS4Tjt62q03PVy5T3DyjyDs4aNpdXgmqn69t/vNExLsvaC5ek1Q59Wxk/8w1oMxZQ GnLQLlx5K7R+2NG7OOoDhRjmQEphyz3qDThdqcAstLqdTY7b7VFpxmI5D5FIWRtezy6G tQGrgIGkGXOLfzqv1xDiyA+uv83A+zkPGRP1KTBPaGOidpt2igFPbH6DPGGTZR9erGC+ XDcwKB7vMJf6JTmQIVQ0riMWJ5aRsNd9w9S6a+i9vtGOT/fTfGFpQPbSJYogGo8udJGL T/hw== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=hJ6xjd0cZYqKXWWAgCQRWdeyZLNHCyKCwiTEIxClln8=; b=RKvIObPYSaFssfONAaOUWb8guf5SBs9pqO2f5CkcclOg/JhpKPlA0swwIOSE6iDWjn vjSqMLXhyrYMiMcAuaZr9IBn208TOYRo/K2tIE4LDJCPr0TTxqqHEHjBJt4ugZXVP8Cn gAkzmI6O210QsktFTwDCiLd3e1I2yJoMeSnvwyAmhPo4yb1GNXrJmwdAc4cLzUG4CHg/ 9ZLMeLTI0Urcw3xOiCgBnrgewW0gefQYn8LJ4b1bngJ1IKAuDbvI956cUhAL+//SxWWW 2hzR9WJv3kENKP8m3nMPYWZhRb7uQLXtQHyXziGLiY+7SrvfUS4asGX9Nm867/PGahXb vZnw== X-Gm-Message-State: AOAM5328nHpigBjBJ4dbJpd2eZ7bNfNbeyhkTdyqfxkE5l5JjVnAn7N6 AXFkGpGBKXb3fmzkV8LvHHZEYw== X-Google-Smtp-Source: ABdhPJyJKjuyfMuDwN2A2oG6hOFPVJBlWYKEZXC7xIQ8jpTXC9GQnikbi/LeD/+9vX3tFxrYEhdINg== X-Received: by 2002:adf:e412:: with SMTP id g18mr15753830wrm.159.1616774223785; Fri, 26 Mar 2021 08:57:03 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:f410:82e8:3a21:eedf]) by smtp.gmail.com with ESMTPSA id r206sm5718437wma.46.2021.03.26.08.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 08:57:02 -0700 (PDT) In-Reply-To: <87k0pu887d.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 26 Mar 2021 12:28:54 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=contovob@tcd.ie; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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:267078 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Stefan Monnier writes: > >>> What's the performance impact here? This is going to be called a whole >>> bunch of times when the user hits TAB... >> >> It should be OK to do the condition-case wrapping around the loop rather >> than within it, so the performance impact should be negligible. > > Yup; if it's hoisted out of the loop, there'd be no performance impact, I see no discernible performance impact even if the condition-case-unless-debug is added into the completing-read predicate, to catch errors from user-provided read-extended-command-predicate values. Running the new attached benchmark with: emacs -Q -batch -f batch-byte-compile bench2.el emacs -Q -l bench2.elc gives the following timing excerpts: TAB RET read-extended-command bench--expensive 1.801461 36 0.568592 nil 0.985272 35 0.552688 command-completion-default-include-p 0.837255 29 0.453390 bench--safe 0.834056 29 0.452686 bench-read-extended-command bench--expensive 1.803410 36 0.566920 nil 0.977062 35 0.549054 command-completion-default-include-p 0.831130 29 0.452036 bench--safe 0.831380 29 0.451495 e w w - TAB C-a C-k RET read-extended-command bench--expensive 1.082884 30 0.415545 nil 0.992358 30 0.417027 command-completion-default-include-p 0.895481 25 0.343474 bench--safe 0.886560 25 0.344851 bench-read-extended-command bench--expensive 1.081067 30 0.414472 nil 0.990662 30 0.415502 command-completion-default-include-p 0.886688 25 0.343094 bench--safe 0.898391 25 0.344109 So back to the original question: do we want this safety net in command-completion-default-include-p, around read-extended-command-predicate (which is user-customisable), or not at all? And if we do add it, should it include a helpful message as per Michael's suggestion? I'm happy either way. -- Basil --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=bench2.el Content-Transfer-Encoding: quoted-printable ;;; bench2.el --- benchmark read-extended-command -*- lexical-binding: t -*- ;; Load libraries with command-modes and completion-predicates. (require 'bookmark) (require 'dbus) (require 'eww) (require 'finder) (require 'gnus-salt) (require 'info) (require 'man) (require 'shr) (require 'tramp-cmds) (require 'tramp-crypt) ;; Custom read-extended-command-predicates. (defun bench--safe (symbol buffer) (if (get symbol 'completion-predicate) (condition-case-unless-debug err (funcall (get symbol 'completion-predicate) symbol buffer) (error (message "command-completion-default-include-p: %s: %S" symbol err) nil)) (or (null (command-modes symbol)) (command-completion-using-modes-p symbol buffer)))) (defun bench--expensive (_symbol _buffer) (let ((i 1000)) (dotimes (_ i) (setq i (1+ i))) i)) ;; Custom read-extended-command. (defun bench-read-extended-command () (let ((buffer (current-buffer))) (minibuffer-with-setup-hook (lambda () (add-hook 'post-self-insert-hook (lambda () (setq execute-extended-command--last-typed (minibuffer-contents))) nil 'local) (setq-local minibuffer-default-add-function (lambda () ;; Get a command name at point in the original buffer ;; to propose it after M-n. (let ((def (with-current-buffer (window-buffer (minibuffer-selected-window)) (and (commandp (function-called-at-point)) (format "%S" (function-called-at-point))))) (all (sort (minibuffer-default-add-completions) #'string<))) (if def (cons def (delete def all)) all))))) ;; Read a string, completing from and restricting to the set of ;; all defined commands. Don't provide any initial input. ;; Save the command read on the extended-command history list. (completing-read (concat (cond ((eq current-prefix-arg '-) "- ") ((and (consp current-prefix-arg) (eq (car current-prefix-arg) 4)) "C-u ") ((and (consp current-prefix-arg) (integerp (car current-prefix-arg))) (format "%d " (car current-prefix-arg))) ((integerp current-prefix-arg) (format "%d " current-prefix-arg))) ;; This isn't strictly correct if `execute-extended-command' ;; is bound to anything else (e.g. [menu]). ;; It could use (key-description (this-single-command-keys)), ;; but actually a prompt other than "M-x" would be confusing, ;; because "M-x" is a well-known prompt to read a command ;; and it serves as a shorthand for "Extended command: ". (if (memq 'shift (event-modifiers last-command-event)) "M-X " "M-x ")) (lambda (string pred action) (if (and suggest-key-bindings (eq action 'metadata)) '(metadata (affixation-function . read-extended-command--affixation) (category . command)) (complete-with-action action obarray string pred))) (lambda (sym) (and (commandp sym) (or (null read-extended-command-predicate) (and (functionp read-extended-command-predicate) (condition-case-unless-debug err (funcall read-extended-command-predicate sym buf= fer) (error (message "command-completion-default-include-p: %s: %S" sym err))))))) t nil 'extended-command-history)))) ;; Benchmarks. (with-current-buffer-window "*bench*" nil nil (pcase-dolist (`(,reps . ,keys) '((10 . "\C-i\C-m") (100 . "eww-\C-i\C-a\C-k\C-m"))) (insert (if (bobp) "" ?\n) (key-description keys) ?\n) (setq keys (listify-key-sequence keys)) (dotimes (_ 3) (insert ?\n) (dolist (fn '(read-extended-command bench-read-extended-command)) (insert (symbol-name fn) ?\n) (dolist (pred '(bench--expensive nil command-completion-default-include-p bench--safe)) (let ((read-extended-command-predicate pred)) (garbage-collect) (insert (apply #'format " %-36s %f %d %f\n" pred (benchmark-run reps (setq unread-command-events keys) (funcall fn)))))))))) ;;; bench2.el ends here --=-=-=--