unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* menu-bar: disable items when no frame visible
@ 2005-11-10 15:57 David Reitter
  2005-11-10 16:03 ` David Reitter
                   ` (2 more replies)
  0 siblings, 3 replies; 71+ messages in thread
From: David Reitter @ 2005-11-10 15:57 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 277 bytes --]

This patch ensures that menu items are disabled when they should be,  
i.e. when there is no applicable visible and non-iconified frame.
In a lot of cases, one could do "insert file" or choose stuff from  
the "search" menu even if there were only iconified or hidden frames.


[-- Attachment #1.1.2: menu-bar-visible-frame.patch --]
[-- Type: application/octet-stream, Size: 8113 bytes --]

Index: menu-bar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/menu-bar.el,v
retrieving revision 1.278
diff -c -r1.278 menu-bar.el
*** menu-bar.el	1 Nov 2005 23:21:39 -0000	1.278
--- menu-bar.el	10 Nov 2005 15:50:18 -0000
***************
*** 172,177 ****
--- 172,178 ----
    '(menu-item "Save" save-buffer
  	      :enable (and (buffer-modified-p)
  			   (buffer-file-name)
+ 			   (menu-bar-menu-frame-live-and-visible-p)
  			   (menu-bar-non-minibuffer-window-p))
  	      :help "Save current buffer to its file"))
  
***************
*** 184,190 ****
  	      :help "Discard (kill) current buffer"))
  (define-key menu-bar-file-menu [insert-file]
    '(menu-item "Insert File..." insert-file
! 	      :enable (menu-bar-non-minibuffer-window-p)
  	      :help "Insert another file into current buffer"))
  (define-key menu-bar-file-menu [dired]
    '(menu-item "Open Directory..." dired
--- 185,192 ----
  	      :help "Discard (kill) current buffer"))
  (define-key menu-bar-file-menu [insert-file]
    '(menu-item "Insert File..." insert-file
! 	      :enable (and (menu-bar-non-minibuffer-window-p)
! 			   (menu-bar-menu-frame-live-and-visible-p))
  	      :help "Insert another file into current buffer"))
  (define-key menu-bar-file-menu [dired]
    '(menu-item "Open Directory..." dired
***************
*** 192,202 ****
  	      :help "Read a directory, to operate on its files"))
  (define-key menu-bar-file-menu [open-file]
    '(menu-item "Open File..." find-file-existing
! 	      :enable (menu-bar-non-minibuffer-window-p)
  	      :help "Read an existing file into an Emacs buffer"))
  (define-key menu-bar-file-menu [new-file]
    '(menu-item "Visit New File..." find-file
! 	      :enable (menu-bar-non-minibuffer-window-p)
  	      :help "Specify a new file's name, to edit the file"))
  
  \f
--- 194,206 ----
  	      :help "Read a directory, to operate on its files"))
  (define-key menu-bar-file-menu [open-file]
    '(menu-item "Open File..." find-file-existing
! 	      :enable (or enable-recursive-minibuffers
! 		       (menu-bar-non-minibuffer-window-p))
  	      :help "Read an existing file into an Emacs buffer"))
  (define-key menu-bar-file-menu [new-file]
    '(menu-item "Visit New File..." find-file
! 	      :enable (or enable-recursive-minibuffers
! 			  (menu-bar-non-minibuffer-window-p))
  	      :help "Specify a new file's name, to edit the file"))
  
  \f
***************
*** 359,364 ****
--- 363,369 ----
  ;;; Assemble the top-level Edit menu items.
  (define-key menu-bar-edit-menu [props]
    '(menu-item "Text Properties" facemenu-menu
+ 	      :enable (menu-bar-menu-frame-live-and-visible-p)
  	      :help "Change properties of text in region"))
  
  (define-key menu-bar-edit-menu [fill]
***************
*** 371,377 ****
    '(menu-item "--"))
  
  (define-key menu-bar-edit-menu [bookmark]
!   '(menu-item "Bookmarks" menu-bar-bookmark-map
  	      :help "Record positions and jump between them"))
  
  (defvar menu-bar-goto-menu (make-sparse-keymap "Go To"))
--- 376,382 ----
    '(menu-item "--"))
  
  (define-key menu-bar-edit-menu [bookmark]
!   `(menu-item "Bookmarks" ,menu-bar-bookmark-map
  	      :help "Record positions and jump between them"))
  
  (defvar menu-bar-goto-menu (make-sparse-keymap "Go To"))
***************
*** 431,450 ****
  	      :help "Read a line number and go to that line"))
  
  (define-key menu-bar-edit-menu [goto]
!   (list 'menu-item "Go To" menu-bar-goto-menu))
  
  (define-key menu-bar-edit-menu [replace]
!   (list 'menu-item "Replace" menu-bar-replace-menu))
  
  (define-key menu-bar-edit-menu [search]
!   (list 'menu-item "Search" menu-bar-search-menu))
  
  (define-key menu-bar-edit-menu [separator-search]
    '(menu-item "--"))
  
  (define-key menu-bar-edit-menu [mark-whole-buffer]
    '(menu-item "Select All" mark-whole-buffer
  	      :help "Mark the whole buffer for a subsequent cut/copy."))
  (define-key menu-bar-edit-menu [clear]
    '(menu-item "Clear" delete-region
  	      :enable (and mark-active
--- 436,459 ----
  	      :help "Read a line number and go to that line"))
  
  (define-key menu-bar-edit-menu [goto]
!   `(menu-item "Go To" ,menu-bar-goto-menu
! 	        :enable (menu-bar-menu-frame-live-and-visible-p)))
  
  (define-key menu-bar-edit-menu [replace]
!   `(menu-item "Replace" ,menu-bar-replace-menu
! 	      :enable (menu-bar-menu-frame-live-and-visible-p)))
  
  (define-key menu-bar-edit-menu [search]
!   `(menu-item "Search" ,menu-bar-search-menu
! 	      :enable (menu-bar-menu-frame-live-and-visible-p)))
  
  (define-key menu-bar-edit-menu [separator-search]
    '(menu-item "--"))
  
  (define-key menu-bar-edit-menu [mark-whole-buffer]
    '(menu-item "Select All" mark-whole-buffer
+ 	      :enable (menu-bar-menu-frame-live-and-visible-p)
  	      :help "Mark the whole buffer for a subsequent cut/copy."))
  (define-key menu-bar-edit-menu [clear]
    '(menu-item "Clear" delete-region
  	      :enable (and mark-active
***************
*** 456,462 ****
  (fset 'yank-menu (cons 'keymap yank-menu))
  (define-key menu-bar-edit-menu [select-paste]
    '(menu-item "Select and Paste" yank-menu
! 	      :enable (and (cdr yank-menu) (not buffer-read-only))
  	      :help "Paste (yank) text cut or copied earlier"))
  (define-key menu-bar-edit-menu [paste]
    '(menu-item "Paste" yank
--- 466,474 ----
  (fset 'yank-menu (cons 'keymap yank-menu))
  (define-key menu-bar-edit-menu [select-paste]
    '(menu-item "Select and Paste" yank-menu
! 	      :enable (and (cdr yank-menu) 
! 			   (not buffer-read-only)
! 			   (menu-bar-menu-frame-live-and-visible-p))
  	      :help "Paste (yank) text cut or copied earlier"))
  (define-key menu-bar-edit-menu [paste]
    '(menu-item "Paste" yank
***************
*** 464,470 ****
  		       ;; Emacs compiled --without-x doesn't have
  		       ;; x-selection-exists-p.
  		       (fboundp 'x-selection-exists-p)
! 		       (x-selection-exists-p) (not buffer-read-only))
  	      :help "Paste (yank) text most recently cut/copied"))
  (define-key menu-bar-edit-menu [copy]
    '(menu-item "Copy" menu-bar-kill-ring-save
--- 476,483 ----
  		       ;; Emacs compiled --without-x doesn't have
  		       ;; x-selection-exists-p.
  		       (fboundp 'x-selection-exists-p)
! 		       (x-selection-exists-p) (not buffer-read-only)
! 		       (menu-bar-menu-frame-live-and-visible-p))
  	      :help "Paste (yank) text most recently cut/copied"))
  (define-key menu-bar-edit-menu [copy]
    '(menu-item "Copy" menu-bar-kill-ring-save
***************
*** 479,484 ****
--- 492,498 ----
  (define-key menu-bar-edit-menu [undo]
    '(menu-item "Undo" undo
  	      :enable (and (not buffer-read-only)
+ 			   (menu-bar-menu-frame-live-and-visible-p)
  			   (not (eq t buffer-undo-list))
  			   (if (eq last-command 'undo)
  			       pending-undo-list
***************
*** 1427,1433 ****
    (let ((menu-frame (if (display-multi-frame-p) menu-updating-frame
  		      (selected-frame))))
      (and (frame-live-p menu-frame)
! 	 (frame-visible-p menu-frame))))
  
  (defun menu-bar-non-minibuffer-window-p ()
    "Return non-nil if selected window of the menu frame is not a minibuf window.
--- 1433,1441 ----
    (let ((menu-frame (if (display-multi-frame-p) menu-updating-frame
  		      (selected-frame))))
      (and (frame-live-p menu-frame)
! 	 (frame-visible-p menu-frame)
! 	 (not (frame-iconified-p (selected-frame))))))
!   
  
  (defun menu-bar-non-minibuffer-window-p ()
    "Return non-nil if selected window of the menu frame is not a minibuf window.
***************
*** 1451,1456 ****
--- 1459,1465 ----
  	  (setq count (1+ count)))
        (setq buffers (cdr buffers)))
      (and (menu-bar-non-minibuffer-window-p)
+ 	 (menu-bar-menu-frame-live-and-visible-p)
  	 (> count 1))))
  
  (put 'dired 'menu-enable '(menu-bar-non-minibuffer-window-p))

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2400 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2005-12-27 19:55 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-10 15:57 menu-bar: disable items when no frame visible David Reitter
2005-11-10 16:03 ` David Reitter
2005-11-10 21:12   ` David Reitter
2005-11-12  3:38     ` Richard M. Stallman
2005-11-12  7:11       ` Eli Zaretskii
2005-11-12 21:21         ` Richard M. Stallman
2005-11-12 22:44           ` Eli Zaretskii
2005-11-28  0:21         ` David Reitter
2005-11-28  5:32           ` Eli Zaretskii
2005-11-28 20:23             ` Juri Linkov
2005-11-28 21:00             ` Richard M. Stallman
2005-11-28 22:20               ` David Reitter
2005-11-28 22:46               ` Jason Rumney
2005-11-29 10:32                 ` Reiner Steib
2005-11-29 21:48                 ` Richard M. Stallman
2005-12-06  0:54                   ` Juri Linkov
2005-12-06 16:43                     ` Richard M. Stallman
2005-12-07  0:45                       ` Juri Linkov
2005-12-07 22:58                         ` Richard M. Stallman
2005-12-12  8:23                           ` Jan D.
2005-12-12 21:14                             ` Eli Zaretskii
2005-12-13  7:19                               ` Jan Djärv
2005-12-13 20:24                                 ` Eli Zaretskii
2005-12-14 17:03                                   ` Juri Linkov
2005-12-14 19:25                                     ` Eli Zaretskii
2005-12-16  9:04                                       ` Juri Linkov
2005-12-16 11:29                                         ` Eli Zaretskii
2005-12-16 12:55                                           ` Juri Linkov
2005-12-16 13:14                                             ` Eli Zaretskii
2005-12-16 14:27                                               ` Juri Linkov
2005-12-16 15:24                                                 ` Eli Zaretskii
2005-12-17 10:54                                                   ` Juri Linkov
2005-12-14 21:25                                     ` Drew Adams
2005-12-15  4:33                                       ` Eli Zaretskii
2005-12-13  3:15                             ` Richard M. Stallman
2005-12-16  9:05                             ` Juri Linkov
2005-12-16 17:40                               ` Jan Djärv
2005-12-17 10:47                                 ` Juri Linkov
2005-12-20 21:55       ` Juri Linkov
2005-12-23 20:43         ` Juri Linkov
2005-12-24 12:15           ` David Reitter
2005-12-24 20:07             ` Juri Linkov
2005-12-24 22:59               ` David Reitter
2005-12-25 16:54                 ` Stefan Monnier
2005-12-25  2:51             ` Richard M. Stallman
2005-12-25  6:44               ` Eli Zaretskii
2005-12-26  2:19                 ` Richard M. Stallman
2005-12-26  5:06                   ` Eli Zaretskii
2005-12-25  9:54               ` David Reitter
2005-12-26  2:19                 ` Richard M. Stallman
2005-12-25 16:58               ` Stefan Monnier
     [not found]               ` <87x6v29lvv.fsf-monnier+emacs@gnu.org>
2005-12-26  2:20                 ` Richard M. Stallman
2005-12-26 16:02                   ` Stefan Monnier
2005-12-26 21:56                     ` Richard M. Stallman
2005-12-27 19:01                       ` Juri Linkov
2005-12-27 19:55                         ` Stefan Monnier
2005-12-24 16:32           ` Richard M. Stallman
2005-12-24 20:12             ` Juri Linkov
2005-11-10 19:34 ` Eli Zaretskii
2005-11-10 19:39   ` David Reitter
2005-11-11  8:33     ` Eli Zaretskii
2005-11-12  3:38       ` Richard M. Stallman
2005-11-28 20:23 ` Juri Linkov
2005-11-28 22:17   ` David Reitter
2005-11-28 22:44     ` Juri Linkov
2005-11-29  0:08       ` David Reitter
2005-11-29  9:03         ` Juri Linkov
2005-11-29  9:02       ` Juri Linkov
2005-11-29  3:10   ` Richard M. Stallman
2005-11-29  9:01     ` Juri Linkov
2005-11-29 21:47       ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).