From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Call CMD w/ keybinding VS execute-extended-command: redisplay behaviour Date: Sun, 25 Mar 2018 18:32:38 +0900 Message-ID: <877eq05wll.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521970256 30454 195.159.176.226 (25 Mar 2018 09:30:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Mar 2018 09:30:56 +0000 (UTC) Cc: Tino Calancha To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 25 11:30:51 2018 Return-path: Envelope-to: ged-emacs-devel@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 1f01zH-0007p8-Gy for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2018 11:30:51 +0200 Original-Received: from localhost ([::1]:50536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f021K-0008KO-Fp for ged-emacs-devel@m.gmane.org; Sun, 25 Mar 2018 05:32:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0218-0008K0-Na for emacs-devel@gnu.org; Sun, 25 Mar 2018 05:32:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0215-0005nt-5p for emacs-devel@gnu.org; Sun, 25 Mar 2018 05:32:46 -0400 Original-Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:37552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0214-0005ni-Um for emacs-devel@gnu.org; Sun, 25 Mar 2018 05:32:43 -0400 Original-Received: by mail-pf0-x233.google.com with SMTP id t16so2155256pfh.4 for ; Sun, 25 Mar 2018 02:32:42 -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:mime-version; bh=oFs1O2Vrh4VhRuqx7+EWeDkYwy+9SuD8fG54PeR7kPw=; b=qbcmyErscs2eppD2g6+wmujK7KxYlD0soamUxENi3/zazs9jFypOVGwDeL4KlLU0sC Xbd1LYb8XVJL/rbge3noWm29sNRPqZgB56BjoNJd9oViiY+MKlVH3GEUb89Weq0Olyqh Qda0PmrAmlLNWSIbrgcmXMWfmxQT0n/f4VzG95IBrXOpCUFkbNKGcjtoPuuEzSPMVIV9 ziGnmoJc/QspNjnGffGrdZNXvSWcqdKOpk4Yg1GbEK3ZOn17oTn7p3KFzpobcfOvjbVR byfbKQnYGsYtx6F7DmAo6Zherdj5pJRYD6m+rS4cr6HhXppHMCoWCKNCYKkgMDuFHxnM hopA== 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:mime-version; bh=oFs1O2Vrh4VhRuqx7+EWeDkYwy+9SuD8fG54PeR7kPw=; b=hmK5AYdJsEBzylZsa8dbWFoFTG2uGqFNx0OegKNzcSnXYEH/nxERaUR5TAB6fzvcnS wsxKUUgXddS6Jf/rU4jOPv5BI4XqZGQZmpsJwvcCf9hcekdKfY3mJNr578Xf4vET4bGV hVP8axSUBjkFOoO08KcGSfTSI5R3RLu3vvLN9EZwuAuhY5TjJB/40TZwwGtB6N3X2JSf lwfQDow2rp1qY4UnrFFH+j2eQQt/UPMLCC0Wd2TXc0IWq/A3uAD8EiCZ1Sd+ZHsz3cQF k7UV2fs29ERwSp7ZFJAJvYAbH3MUueYEIznezXYfAOuXb9KJCCLGysYQNBCQuSKtHEEQ PSuw== X-Gm-Message-State: AElRT7EkrrmEdSnvkfXWGyh5xqCD4i1UlYjJmLR7YxEBamQR9DuWxXbf 044ZAHH0ooq2AXK8vfcmz+U= X-Google-Smtp-Source: AG47ELsVQASCIWDtIx+IUy7v198eO2ylCd2kr3Tyz4vjAIKeS50SZIFu7m9zbcduD2YkNf/WVwjOGA== X-Received: by 10.98.71.211 with SMTP id p80mr12047564pfi.136.1521970361780; Sun, 25 Mar 2018 02:32:41 -0700 (PDT) Original-Received: from calancha-pc (121.7.236.133.dy.bbexcite.jp. [133.236.7.121]) by smtp.gmail.com with ESMTPSA id s78sm26074091pfa.161.2018.03.25.02.32.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Mar 2018 02:32:40 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:223991 Archived-At: Dear Emacs, I have defined a command (see below snippet code) which updates the header line in a buffer inheriting from tabulated-list. The effect on the header line is visible inmediately, i.e., the screen is automatically redisplayed, but... * If I bind this command to 'r', then there is no automatic redisplay anymore; I need to push some keys until a window redisplay is fired. * If I call the command and rigth after run `repeat', i.e. `C-x z' then the header line is not automatically updated either. Is there a reason why it is preferable this distintion between calling a command with a keybinding VS calling it via `execute-extended-command'? I wish the keybinding 'r' update the screen as well. How can I do that? Note: I don't want to revert the buffer, just redisplay the header line. To reproduce, create a file foo.el with following content: --8<-----------------------------cut here---------------start------------->8--- (defvar foo-format [("Category" 12 t) ("Knight (best friend: hadoken)" 30 t) ("Energy" 50 t)] "Table format.") (defvar foo-mode nil "Save status of the `foo-mode'.") (defun foo-tabulated-list-entries () (setq tabulated-list-entries '((1 ["bronze" "Seiya" "98"]) (2 ["bronze" "Shiryu" "95"]))) (tabulated-list-init-header)) (defun foo () (interactive) (let ((foo-buffer (generate-new-buffer "*foo*"))) (switch-to-buffer foo-buffer) (or foo-mode (foo-mode)) (setq tabulated-list-use-header-line t) (foo-tabulated-list-entries) (tabulated-list-print))) (defun foo--new-knight() (let ((knights '("Ikki" "Shun" "Hyoga"))) (nth (random (length knights)) knights))) (defun foo-update-friend() "Update header line with new friend." (interactive) (let ((regexp "Knight (best friend: \\([^)]+\\))") (knight-new (foo--new-knight))) (when (string-match regexp header-line-format) (let ((knight (match-string 1 header-line-format))) (while (string= knight knight-new) (setq knight-new (foo--new-knight))) (setq header-line-format (replace-match knight-new nil nil header-line-format 1)) (message "Updated knight to: '%s'" knight-new) ;; Don't regenerate all rows because it might be expensive; ;; just redisplay the header line. (redisplay))))) ;;; Foo Mode map (defvar foo-mode-map (let ((map (make-keymap))) (define-key map (kbd "r") 'foo-update-friend) map)) ;;; Define mode (define-derived-mode foo-mode tabulated-list-mode "Foo" (setq tabulated-list-format foo-format)) --8<-----------------------------cut here---------------end--------------->8--- emacs -Q -l foo.el: M-x foo RET ;; Note the difference between the following: M-x foo-update-friend RET ;; Updates the knight's friend in the header line, i.e., the name ;; showed in the minibuffer matches the friend name in the header line. r ;; It doesn't update the knight's friend; you can see that name in the ;; minibuffer doesn't match the one in the header line. If you input ;; something for example if you use the down arrow, then the header ;; line is updated.