From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#43383: 26.3; `toggle-menu-bar-mode-from-frame' Date: Mon, 14 Sep 2020 01:30:03 +0200 Message-ID: <87tuw1dzlw.fsf@gnus.org> References: <7f20fd70-b8f0-490d-a3f8-36a7554c6ccd@default> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24881"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 43383@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 14 01:31:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kHbSg-0006Mr-EY for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Sep 2020 01:31:10 +0200 Original-Received: from localhost ([::1]:39992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHbSe-000283-VY for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Sep 2020 19:31:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHbSY-00027w-CM for bug-gnu-emacs@gnu.org; Sun, 13 Sep 2020 19:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kHbSY-0000pr-30 for bug-gnu-emacs@gnu.org; Sun, 13 Sep 2020 19:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kHbSX-0003iS-W4 for bug-gnu-emacs@gnu.org; Sun, 13 Sep 2020 19:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Sep 2020 23:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43383 X-GNU-PR-Package: emacs Original-Received: via spool by 43383-submit@debbugs.gnu.org id=B43383.160003981711666 (code B ref 43383); Sun, 13 Sep 2020 23:31:01 +0000 Original-Received: (at 43383) by debbugs.gnu.org; 13 Sep 2020 23:30:17 +0000 Original-Received: from localhost ([127.0.0.1]:52052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHbRo-00031b-Ng for submit@debbugs.gnu.org; Sun, 13 Sep 2020 19:30:17 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:50630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHbRm-0002to-Jv for 43383@debbugs.gnu.org; Sun, 13 Sep 2020 19:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=p8Bb4vq3cxAp9JNsDKsRxG+4DFzoWSSGy+XK32laFjE=; b=ACwtqh9wzAVvl17i51gU+wHX6K rtjFDfGa7BGcPT/M7dZqUFfDpRJePRaqw/dYrqF2vzyEiG0UZ0fkzR4fpHwGNlcVixq8XPR9033+/ 9D/2LA4MvgwiWORojb//90kxEBWQVHsOoKCLCZgroDxSXvzKSVmfpYEFRI2Z7pM6Agio=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kHbRc-00016z-Ox; Mon, 14 Sep 2020 01:30:08 +0200 X-Now-Playing: Rema Rema's _Fond Reflections (1): Wheel in the Roses (Extended)_: "Feedback Song" In-Reply-To: <7f20fd70-b8f0-490d-a3f8-36a7554c6ccd@default> (Drew Adams's message of "Sun, 13 Sep 2020 20:58:16 +0000 (UTC)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188009 Archived-At: Drew Adams writes: > I don't understand the doc string: > > Toggle menu bar on or off, based on the status of the current frame. > See `menu-bar-mode' for more information. > > I have no idea what is meant by "based on the status of the current > frame". Is the status whether it shows the menu-bar? > > Furthermore, this seems to be used only in menu Options > Show/Hide. > Which means it's only visible when the menu-bar is visible, right? It's very confusing indeed, but the patch that introduces this has a long essay about why it was added. It's something to do with... multi-tty? Which clarifies the meaning of "Toggle menu bar on or off, based on the status of the current frame." somewhat, since the exegesis says that the (global) status may be... wrong? That sounds like a bug, doesn't it? commit 6a5af08f8d3bb831a78edf17e9c38813bbfbb6f8 Author: Karoly Lorentey AuthorDate: Sun Mar 26 14:20:01 2006 +0000 Commit: Karoly Lorentey CommitDate: Sun Mar 26 14:20:01 2006 +0000 Fix tool-bar and menu-bar toggles in Show/Hide menu to reflect the state of the current frame. * lisp/tool-bar.el (toggle-tool-bar-mode-from-frame): New function. * lisp/menu-bar.el (toggle-menu-bar-mode-from-frame): New function. (menu-bar-showhide-menu): Use them to change "Menu-bar" and "Tool-bar" toggles to reflect the state of the current frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-537 diff --git a/README.multi-tty b/README.multi-tty index 2ac27bafe5..442c4c92fd 100644 --- a/README.multi-tty +++ b/README.multi-tty @@ -404,17 +404,6 @@ is probably not very interesting for anyone else.) THINGS TO DO ------------ -** `tool-bar-mode', `scroll-bar-mode', `menu-bar-mode' and - 'fringe-mode' are modes global to the entire Emacs session, not - just a single frame or a single terminal. This means that their - status sometimes differs from what's actually displayed on the - screen. As a consequence, the Options | Show/Hide menu sometimes - shows incorrect status, and you have to select an option twice for - it to have any visible effect on the current frame. - - Change Emacs so that the status of the items in the Options | - Show/Hide menu correspond to the current frame. - ** emacsclient -t on the console does not work after su: # su lorentey @@ -1485,5 +1474,18 @@ DIARY OF CHANGES (Done in patch-500.) +-- `tool-bar-mode', `scroll-bar-mode', `menu-bar-mode' and + 'fringe-mode' are modes global to the entire Emacs session, not + just a single frame or a single terminal. This means that their + status sometimes differs from what's actually displayed on the + screen. As a consequence, the Options | Show/Hide menu sometimes + shows incorrect status, and you have to select an option twice for + it to have any visible effect on the current frame. + + Change Emacs so that the status of the items in the Options | + Show/Hide menu correspond to the current frame. + + (Done in patch-537.) + ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 75d68d0baa..a9987d589f 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -935,15 +935,15 @@ menu-bar-showhide-menu :button `(:toggle . tooltip-mode))) (define-key menu-bar-showhide-menu [menu-bar-mode] - '(menu-item "Menu-bar" menu-bar-mode + '(menu-item "Menu-bar" toggle-menu-bar-mode-from-frame :help "Toggle menu-bar on/off" - :button (:toggle . menu-bar-mode))) + :button (:toggle . (> (frame-parameter nil 'menu-bar-lines) 0)))) (define-key menu-bar-showhide-menu [showhide-tool-bar] - (list 'menu-item "Tool-bar" 'tool-bar-mode - :help "Turn tool-bar on/off" + (list 'menu-item "Tool-bar" 'toggle-tool-bar-mode-from-frame + :help "Toggle tool-bar on/off" :visible `(display-graphic-p) - :button `(:toggle . tool-bar-mode))) + :button `(:toggle . (> (frame-parameter nil 'tool-bar-lines) 0)))) (define-key menu-bar-options-menu [showhide] (list 'menu-item "Show/Hide" menu-bar-showhide-menu @@ -1778,6 +1778,14 @@ menu-bar-mode "Menu-bar mode disabled. Use M-x menu-bar-mode to make the menu bar appear.")) menu-bar-mode) +(defun toggle-menu-bar-mode-from-frame (&optional arg) + "Toggle menu bar on or off, based on the status of the current frame. +See `menu-bar-mode' for more information." + (interactive (list (or current-prefix-arg 'toggle))) + (if (eq arg 'toggle) + (menu-bar-mode (if (> (frame-parameter nil 'menu-bar-lines) 0) 0 1)) + (menu-bar-mode arg))) + (provide 'menu-bar) ;;; arch-tag: 6e6a3c22-4ec4-4d3d-8190-583f8ef94ced diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el index be552854b1..023b90af5d 100644 --- a/lisp/tool-bar.el +++ b/lisp/tool-bar.el @@ -61,6 +61,16 @@ tool-bar-mode (display-graphic-p)) (tool-bar-setup)))) +;;;###autoload +;; Used in the Show/Hide menu, to have the toggle reflect the current frame. +(defun toggle-tool-bar-mode-from-frame (&optional arg) + "Toggle tool bar on or off, based on the status of the current frame. +See `tool-bar-mode' for more information." + (interactive (list (or current-prefix-arg 'toggle))) + (if (eq arg 'toggle) + (tool-bar-mode (if (> (frame-parameter nil 'tool-bar-lines) 0) 0 1)) + (tool-bar-mode arg))) + ;;;###autoload ;; We want to pretend the toolbar by standard is on, as this will make ;; customize consider disabling the toolbar a customization, and save -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no