[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: w3m-pop-up-windows and w3m-use-tab [PATCH]



In [emacs-w3m:12936]
On Mon, 12 Mar 2018 07:04:28 -0400, Boruch Baum wrote:
> I'm attaching a first version of a patch this quickly because its nature
> turned out to be over 90% documentation for clarity, and the actual code
> amounts to simple and modular plug-ins. However, at this point I've only
> done minor testing on it, so I'm sharing it primarily for its
> documentation value. Don't get me wrong - if anyone has got some time
> and wants to evaluate it, great.

Thanks.  But, er, I'd like to go a simple way. :-)
My solution (attached) is only to add the `w3m-display-mode'
option.

When customizing `w3m-display-mode' to a non-nil value, the
three variables `w3m-use-tab', `w3m-pop-up-windows' and
`w3m-pop-up-frames' will be modified according to the mode.

When resetting `w3m-display-mode' to nil, the values of the
three variables will be restored as before.

Note that evaluating (setq w3m-display-mode 'mode) is not
effective.  Please see the docstring.
--- w3m.el~	2018-02-27 06:23:35.000000000 +0000
+++ w3m.el	2018-03-13 08:39:38.561211900 +0000
@@ -11537,6 +11537,102 @@
 	    (load w3m-init-file t t t))
       (load w3m-init-file t t))))
 
+;; This form should be placed here (after loading the init file).
+(defcustom w3m-display-mode nil
+  "How to display emacs-w3m buffers.
+
+There exist five display modes for emacs-w3m called interactively:
+`plain', `tabbed', `dual-pane', `dedicated-frames', and
+`tabbed-dedicated-frames'.
+
+These modes are set by a combination of three variables `w3m-use-tab',
+`w3m-pop-up-windows' and `w3m-pop-up-frames', but can now be set with
+this single setting `w3m-display-mode'.  When this variable is set,
+those three variables will be modified according to the display mode.
+
+You should use `customize-option' (or `customize-option-other-window')
+to customize this variable.  Otherwise add a form
+
+(setq w3m-display-mode 'MODE)
+
+to the ~/.emacs-w3m.el file.  Where MODE is one of the following modes
+or nil that means not to modify `w3m-use-tab', `w3m-pop-up-windows' or
+`w3m-pop-up-frames'.
+
+`plain'
+Each emacs-w3m buffer exists on its own and can appear in any window
+in any frame, although a reasonable attempt will be made to re-use
+an existing window.  There is no tab bar.  This mode is set by
+the combination: `w3m-use-tab' nil, `w3m-pop-up-windows' nil, and
+`w3m-pop-up-frames' nil.
+
+`tabbed'
+A reasonable attempt is made to keep only one window displaying
+emacs-w3m buffers.  That window has a cliackable tab bar along the top.
+Users can manually subvert this by explicitly opening an emacs-w3m
+buffer in any number of other windows.  This mode is set by
+the combination: `w3m-use-tab' t, `w3m-pop-up-windows' ignored, and
+`w3m-pop-up-frames' nil.
+
+`dual-pane'
+Once more than one emacs-w3m buffer exists, a reasonable attempt is
+made to present emacs-w3m in two windows on the same frame.  Any action
+to open a new emacs-w3m buffer, such as `w3m-goto-url-new-session' or
+`w3m-search-new-session' displays the new buffer in the unfocused pane,
+and transfers focus there.  This mode is set by the combination:
+`w3m-use-tab' nil `w3m-pop-up-windows' t, and `w3m-pop-up-frames' nil.
+
+`dedicated-frames'
+Each new emacs-w3m buffer is opened in a new single-window frame.
+This mode is set the combination: `w3m-use-tab' nil,
+`w3m-pop-up-windows' ignored, and `w3m-pop-up-frames' t.
+
+`tabbed-dedicated-frames'
+Each new emacs-w3m buffer is opened in the same window of the frame
+from which it was spawned, and is not easily visible to emacs-w3m
+buffers associated with other frames.  The window includes a clickable
+tab bar along the top.  This mode is set by the combination:
+`w3m-use-tab' t `w3m-pop-up-windows' ignored, and `w3m-pop-up-frames'
+t."
+  :group 'w3m
+  :type '(radio (const :format "Unset" nil)
+		(const :format "Plain" plain)
+		(const :format "Tabbed" tabbed)
+		(const :format "Dual-pane\n" dual-pane)
+		(const :format "Dedicated Frames" frames)
+		(const :format "Tabbed Dedicated Frames" tabbed-frames))
+  :set (lambda (symbol value)
+	 (let (val)
+	   (dolist (var '(w3m-use-tab w3m-pop-up-windows w3m-pop-up-frames))
+	     (unless (setq val (get var 'w3m-custom))
+	       (put var 'w3m-custom (list (symbol-value var))))))
+	 (if value
+	     (progn
+	       (unless (and (boundp symbol) (symbol-value symbol))
+		 (dolist (var '(w3m-use-tab w3m-pop-up-windows
+					    w3m-pop-up-frames))
+		   (put var 'w3m-custom (list (symbol-value var)))))
+	       (cond ((eq value 'plain)
+		      (setq w3m-use-tab nil
+			    w3m-pop-up-windows nil
+			    w3m-pop-up-frames nil))
+		     ((eq value 'tabbed)
+		      (setq w3m-use-tab t
+			    w3m-pop-up-frames nil))
+		     ((eq value 'dual-pane)
+		      (setq w3m-use-tab nil
+			    w3m-pop-up-windows t
+			    w3m-pop-up-frames nil))
+		     ((eq value 'frames)
+		      (setq w3m-use-tab nil
+			    w3m-pop-up-frames t))
+		     ((eq value 'tabbed-frames)
+		      (setq w3m-use-tab t
+			    w3m-pop-up-frames t))))
+	   (dolist (var '(w3m-use-tab w3m-pop-up-windows w3m-pop-up-frames))
+	     (set var (car (get var 'w3m-custom)))))
+	 (custom-set-default symbol value)))
+
 (run-hooks 'w3m-load-hook)
 
 ;;; w3m.el ends here