unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fringe in Show/Hide menu?
@ 2002-04-01 17:19 Pavel Janík
  2002-04-02  6:00 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Pavel Janík @ 2002-04-01 17:19 UTC (permalink / raw)


Hi,

I'd like to see the possibility of turning on/off fringes in Show/Hide
submenu of Options menu. Here is my current code:

2002-04-01  Pavel Janík  <Pavel@Janik.cz>

	* menu-bar.el (menu-bar-showhide-menu): Rename menu items.
	(menu-bar-showhide-fringe-menu): New sub-menu.
	(toggle-fringe): New function.
	(menu-bar-showhide-fringe-menu): New menu-items.

There is one problem - I do not see an easy way of saving this to .emacs
via customize. Do you have an idea?

--- menu-bar.el.~1.205.~	Sun Mar 31 11:12:18 2002
+++ menu-bar.el	Mon Apr  1 18:13:12 2002
@@ -616,7 +616,7 @@
     (message "Display-time mode disabled.")))
 
 (define-key menu-bar-showhide-menu [showhide-date-time]
-  '(menu-item "Date and time" (lambda ()
+  '(menu-item "Date and Time" (lambda ()
 				(interactive)
 				(showhide-date-time)
 				(customize-mark-as-set 'display-time-mode))
@@ -635,6 +635,49 @@
 			      (frame-visible-p 
 			       (symbol-value 'speedbar-frame))))))
 
+(defvar menu-bar-showhide-fringe-menu (make-sparse-keymap "Fringe"))
+
+(defun toggle-fringe (&optional arg)
+  "Toggle fringes on/off.
+ARG can be one of 'left-fringe or 'right-fringe.
+When called interactively, both fringes are toggled"
+  (interactive)
+  (if (null arg)
+      (progn
+	(toggle-fringe 'left-fringe)
+	(toggle-fringe 'right-fringe))
+    (modify-frame-parameters
+     (selected-frame)
+     (list (cons arg
+		 (if (< 0 (cdr (assq arg
+				     (frame-parameters))))
+		     0 nil))))))
+
+(define-key menu-bar-showhide-fringe-menu [right]
+  '(menu-item "On the Right" 
+	      (lambda ()
+		(interactive)
+		(toggle-fringe 'right-fringe))
+	      :help "Turn fringe on the right on/off"
+	      :visible window-system
+	      :button (:toggle . (< 0 (cdr (assq 'right-fringe
+						 (frame-parameters)))))))
+
+(define-key menu-bar-showhide-fringe-menu [left]
+  '(menu-item "On the Left" 
+	      (lambda ()
+		(interactive)
+		(toggle-fringe 'left-fringe))
+	      :help "Turn fringe on the left on/off"
+	      :visible window-system
+	      :button (:toggle . (< 0 (cdr (assq 'left-fringe
+						 (frame-parameters)))))))
+
+(define-key menu-bar-showhide-menu [showhide-fringe]
+  (list 'menu-item "Fringe" menu-bar-showhide-fringe-menu
+	:visible 'window-system
+	:help "Select fringe mode"))
+
 (defvar menu-bar-showhide-scroll-bar-menu (make-sparse-keymap "Scroll-bar"))
 
 (define-key menu-bar-showhide-scroll-bar-menu [right]
@@ -668,7 +711,7 @@
 					       (frame-parameters))) nil))))
 
 (define-key menu-bar-showhide-menu [showhide-scroll-bar]
-  (list 'menu-item "Scroll-Bar" menu-bar-showhide-scroll-bar-menu
+  (list 'menu-item "Scroll-bar" menu-bar-showhide-scroll-bar-menu
 	:visible 'window-system
 	:help "Select scroll-bar mode"))
 

-- 
Pavel Janík

Congratulations. You have been brainwashed by Dan Bernstein.
                  -- Linus Torvalds in linux-kernel

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

* Re: Fringe in Show/Hide menu?
  2002-04-01 17:19 Fringe in Show/Hide menu? Pavel Janík
@ 2002-04-02  6:00 ` Eli Zaretskii
  2002-04-02 12:04 ` Per Abrahamsen
  2002-04-02 18:27 ` Richard Stallman
  2 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2002-04-02  6:00 UTC (permalink / raw)
  Cc: emacs-devel


On Mon, 1 Apr 2002, Pavel =?iso-8859-2?q?Jan=EDk?= wrote:

> +(define-key menu-bar-showhide-fringe-menu [right]
> +  '(menu-item "On the Right" 
> +	      (lambda ()
> +		(interactive)
> +		(toggle-fringe 'right-fringe))
> +	      :help "Turn fringe on the right on/off"
> +	      :visible window-system

Please try to avoid using window-system as much as you can.  In this 
case, it is actually incorrect, since the MS-DOS port defines a non-nil 
value for window-system (for histerical reasons).  More generally, use
of window-system is a time bomb: as Emacs is developed and features that
were once available to certain kinds of displays are made available on 
more display types, the places that use window-system become maintenance 
burden, in the need for constant attention, and a source of bug reports.

It is better to condition such menu items on some feature or function 
that is required for the underlying functionality to work.  For example, 
(fboundp 'some-function-required-for-fringes) could be a good test in 
this case.  If all else fails, display-graphic-p is still better than 
window-system.

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

* Re: Fringe in Show/Hide menu?
  2002-04-01 17:19 Fringe in Show/Hide menu? Pavel Janík
  2002-04-02  6:00 ` Eli Zaretskii
@ 2002-04-02 12:04 ` Per Abrahamsen
  2002-04-02 16:50   ` Pavel Janík
  2002-04-02 18:27 ` Richard Stallman
  2 siblings, 1 reply; 9+ messages in thread
From: Per Abrahamsen @ 2002-04-02 12:04 UTC (permalink / raw)


Pavel@Janik.cz (Pavel Janík) writes:

> There is one problem - I do not see an easy way of saving this to .emacs
> via customize. Do you have an idea?

You basically need to look at menu-bar-mode or tool-bar-mode, and
duplicate the work made for these.

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

* Re: Fringe in Show/Hide menu?
  2002-04-02 12:04 ` Per Abrahamsen
@ 2002-04-02 16:50   ` Pavel Janík
  2002-04-04 15:45     ` Per Abrahamsen
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Janík @ 2002-04-02 16:50 UTC (permalink / raw)
  Cc: emacs-devel

   From: Per Abrahamsen <abraham@dina.kvl.dk>
   Date: Tue, 02 Apr 2002 14:04:34 +0200

   > > There is one problem - I do not see an easy way of saving this to .emacs
   > > via customize. Do you have an idea?
   > 
   > You basically need to look at menu-bar-mode or tool-bar-mode, and
   > duplicate the work made for these.

But fringe is much more customizable (not in Emacs' style right now). You
can have no fringe, left fringe of some width, right fringe of some width,
both fringes etc... It is much more variable, so it is not as simple as it
seems to be.
-- 
Pavel Janík

Avoid unnecessary branches.
                  --  The Elements of Programming Style (Kernighan & Plaugher)

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

* Re: Fringe in Show/Hide menu?
  2002-04-01 17:19 Fringe in Show/Hide menu? Pavel Janík
  2002-04-02  6:00 ` Eli Zaretskii
  2002-04-02 12:04 ` Per Abrahamsen
@ 2002-04-02 18:27 ` Richard Stallman
  2002-04-02 21:52   ` Kim F. Storm
  2 siblings, 1 reply; 9+ messages in thread
From: Richard Stallman @ 2002-04-02 18:27 UTC (permalink / raw)
  Cc: emacs-devel

    There is one problem - I do not see an easy way of saving this to .emacs
    via customize. Do you have an idea?

You need to first define a customizable variable to control the
feature.  Look at the defcustom for menu-bar-mode to see how that can
be done.  Then the menu commands can work by calling a function that
sets that variable and calling customize-mark-as-set.

However, I think it is a very bad idea to nest the menus so deeply.
It is inconvenient to go down thru so many menus.

Instead of having a submenu of fringe hiding commands, it is better
to have one command that cycles thru all 4 possibilities.

I think menu-bar-showhide-scroll-bar-menu is also inconvenient and
should be replaced with a single command to cycle thru all 3
possibilities.

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

* Re: Fringe in Show/Hide menu?
  2002-04-02 18:27 ` Richard Stallman
@ 2002-04-02 21:52   ` Kim F. Storm
  2002-04-02 22:05     ` Stefan Monnier
  2002-04-06 10:01     ` Pavel Janík
  0 siblings, 2 replies; 9+ messages in thread
From: Kim F. Storm @ 2002-04-02 21:52 UTC (permalink / raw)
  Cc: Pavel, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     There is one problem - I do not see an easy way of saving this to .emacs
>     via customize. Do you have an idea?
> 
> You need to first define a customizable variable to control the
> feature.  Look at the defcustom for menu-bar-mode to see how that can
> be done.  Then the menu commands can work by calling a function that
> sets that variable and calling customize-mark-as-set.
> 
> However, I think it is a very bad idea to nest the menus so deeply.
> It is inconvenient to go down thru so many menus.
> 
> Instead of having a submenu of fringe hiding commands, it is better
> to have one command that cycles thru all 4 possibilities.

I disagree.  If the menus are sensible named and structured, I'd
prefer to go through an extra level of menus _once_, rather than
having to go through the whole menu selection _several_ times to cycle
through the unwanted choices (and how do I know what the alternatives
are without doing so?).

> 
> I think menu-bar-showhide-scroll-bar-menu is also inconvenient and
> should be replaced with a single command to cycle thru all 3
> possibilities.

IMO, the current interface is much more user friendly than your
proposal.

And it is still simpler than:

 Help -> Describe -> Describe Language Environment -> European -> latin-1

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

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Fringe in Show/Hide menu?
  2002-04-02 21:52   ` Kim F. Storm
@ 2002-04-02 22:05     ` Stefan Monnier
  2002-04-06 10:01     ` Pavel Janík
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2002-04-02 22:05 UTC (permalink / raw)
  Cc: rms, Pavel, emacs-devel

> > I think menu-bar-showhide-scroll-bar-menu is also inconvenient and
> > should be replaced with a single command to cycle thru all 3
> > possibilities.

I'd prefer something yet-different:
basically, inline the 3 entries of the submenu into the parent (thus
making it larger by 2 entries).
But we should also be able to turn the 3 entries into 2:
- one for on/off
- one for left/right (disabled if the previous one is off)


	Stefan

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

* Re: Fringe in Show/Hide menu?
  2002-04-02 16:50   ` Pavel Janík
@ 2002-04-04 15:45     ` Per Abrahamsen
  0 siblings, 0 replies; 9+ messages in thread
From: Per Abrahamsen @ 2002-04-04 15:45 UTC (permalink / raw)


Pavel@Janik.cz (Pavel Janík) writes:

>    From: Per Abrahamsen <abraham@dina.kvl.dk>
>    Date: Tue, 02 Apr 2002 14:04:34 +0200
>
>    > > There is one problem - I do not see an easy way of saving this to .emacs
>    > > via customize. Do you have an idea?
>    > 
>    > You basically need to look at menu-bar-mode or tool-bar-mode, and
>    > duplicate the work made for these.
>
> But fringe is much more customizable (not in Emacs' style right
> now). 

I do not think this matters much for the loading/saving logic.  It
mostly affects the UI.

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

* Re: Fringe in Show/Hide menu?
  2002-04-02 21:52   ` Kim F. Storm
  2002-04-02 22:05     ` Stefan Monnier
@ 2002-04-06 10:01     ` Pavel Janík
  1 sibling, 0 replies; 9+ messages in thread
From: Pavel Janík @ 2002-04-06 10:01 UTC (permalink / raw)
  Cc: rms, emacs-devel

   From: storm@cua.dk (Kim F. Storm)
   Date: 02 Apr 2002 23:52:09 +0200

   > I disagree.  If the menus are sensible named and structured, I'd
   > prefer to go through an extra level of menus _once_, rather than
   > having to go through the whole menu selection _several_ times to cycle
   > through the unwanted choices (and how do I know what the alternatives
   > are without doing so?).

I agree with Kim here.
-- 
Pavel Janík

# Basic IBM dingbats, some of which will never have a purpose clear
# to mankind
                  -- 2.4.0 drivers/char/cp437.uni

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

end of thread, other threads:[~2002-04-06 10:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-01 17:19 Fringe in Show/Hide menu? Pavel Janík
2002-04-02  6:00 ` Eli Zaretskii
2002-04-02 12:04 ` Per Abrahamsen
2002-04-02 16:50   ` Pavel Janík
2002-04-04 15:45     ` Per Abrahamsen
2002-04-02 18:27 ` Richard Stallman
2002-04-02 21:52   ` Kim F. Storm
2002-04-02 22:05     ` Stefan Monnier
2002-04-06 10:01     ` Pavel Janík

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).