From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: mode-line menu for minor modes Date: Wed, 20 Feb 2008 16:11:44 -0800 Message-ID: <007601c8741e$57f0d120$c2b22382@us.oracle.com> References: <200802190809.m1J89C74001353@sallyv1.ics.uci.edu><008201c87372$3d5b2ab0$0600a8c0@us.oracle.com> <200802200629.m1K6TIoH027637@sallyv1.ics.uci.edu> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1203552832 26602 80.91.229.10 (21 Feb 2008 00:13:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Feb 2008 00:13:52 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 21 01:27:29 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1JRzHb-00023t-Dw for ged-emacs-devel@m.gmane.org; Thu, 21 Feb 2008 01:27:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRz4J-0003RC-E7 for ged-emacs-devel@m.gmane.org; Wed, 20 Feb 2008 19:13:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JRz4D-0003Pm-AB for emacs-devel@gnu.org; Wed, 20 Feb 2008 19:13:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JRz4C-0003PB-O0 for emacs-devel@gnu.org; Wed, 20 Feb 2008 19:13:36 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRz4C-0003P7-D5 for emacs-devel@gnu.org; Wed, 20 Feb 2008 19:13:36 -0500 Original-Received: from rgminet01.oracle.com ([148.87.113.118]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JRz4B-00075u-TY for emacs-devel@gnu.org; Wed, 20 Feb 2008 19:13:36 -0500 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m1L0DW7k013784; Wed, 20 Feb 2008 17:13:32 -0700 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m1KDOe0k031619; Wed, 20 Feb 2008 17:13:32 -0700 Original-Received: from inet-141-146-46-1.oracle.com by acsmt350.oracle.com with ESMTP id 3583747181203552732; Wed, 20 Feb 2008 16:12:12 -0800 Original-Received: from dradamslap1 (/130.35.178.194) by bhmail.oracle.com (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Feb 2008 16:12:11 -0800 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AchzimP4JBq0LJMNT/uMeA1Y/JSPoQAkjoIg In-Reply-To: <200802200629.m1K6TIoH027637@sallyv1.ics.uci.edu> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:89755 Archived-At: > > > The new feature to pop a menu when clicking on the mode-line > > > :lighter for > > > minor modes is great. > > > > > > But for minor modes that don't provide a menu, just an error > > > message is > > > displayed: "No menu for minor mode `BLAH'". This is > > > not very helpful > > > for the user, it would be nicer to pop up a menu that > > > has (at least) 2 > > > entries: - one to turn off the minor mode > > > - one to show the help for that minor mode. > > > > > > Yes, these are available elsewhere, but it's better to > > > provide something > > > useful and consistent for mouse-1 instead of just > > > complaining that a menu is not available. > > > > Good idea. > > Given that you wrote the rest of the minor mode menu popup > code, do you > want to implement this too? OK - see below. I wanted to make a patch, but apparently I don't know how to find the latest CVS version. When I look at what I think would be the latest version, namely the first download link at http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/bindings.el?view=log, it shows a version of bindings.el that does not have the changes I submitted. But you are apparently seeing some version that does include that patch. If you tell me how to find the right version to patch, I'll send a patch. If not, here is the updated function definition - just substitute this for the definition I sent in my September patch. Note: I added (sleep-for 1) because the turned-off message is otherwise erased immediately, at least in my environment. If it works for you without the sleep-for, then go ahead and remove it. (defun minor-mode-menu-from-indicator (indicator) ; e.g. " Icy" "Show menu for minor mode specified by INDICATOR. Interactively, INDICATOR is read using completion. If there is no menu defined for the minor mode, then create one with items `Turn Off' and `Help'." (interactive (list (completing-read "Minor mode indicator: " (describe-minor-mode-completion-table-for-indicator)))) (let ((minor-mode (lookup-minor-mode-from-indicator indicator))) (unless minor-mode (error "Cannot find minor mode for `%s'" indicator)) (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist))) (menu (and (keymapp map) (lookup-key map [menu-bar])))) (if menu (popup-menu menu) (read-event) ; Swallow the mouse up event. (setq menu `(keymap (,(intern indicator) ,indicator keymap (turn-off menu-item "Turn Off" (lambda () (interactive) (,minor-mode -1) (message ,(format "`%S' turned OFF" minor-mode)) (sleep-for 1))) (help menu-item "Help" (lambda () (interactive) (describe-function ',minor-mode)))))) (popup-menu menu)))))