unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: face-remap.el patch to resize window
@ 2009-08-10  1:04 Drew Adams
  2009-08-10  3:00 ` Stefan Monnier
  0 siblings, 1 reply; 20+ messages in thread
From: Drew Adams @ 2009-08-10  1:04 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

Resending - got no response.

Doesn't it make sense to resize the window to take advantage of space freed up
when text is scaled smaller? As an option at least?

Option `text-scale-resize-window' lets you recuperate such space horizontally,
vertically, both, or neither (do nothing).


-----Original Message-----
From: Drew Adams Sent: Monday, June 22, 2009 1:40 PM

Commands `text-scale-decrease', `text-scale-increase', and
`text-scale-adjust' (bound to `C-x C--', `C-x C-+', `C-x C-=',
and `C-x C-0') let you resize the text in the current buffer
by changing its scale factor.

When you shrink or enlarge the apparent text size this way,
however, the window takes no notice of it.  In particular,
although shrinking text can result in extra horizontal
space at the right, window commands do not see this space
as extra (available).

With this patch, user option `text-scale-resize-window' lets
you automatically resize the selected window (horizontally,
vertically, or both) when text is resized, so that the way the
window fits the buffer text remains relatively constant.
Shrinking the text in one window shrinks that window, giving
more space to adjacent windows.

Feel free to change the default value for the option (e.g. to nil, to have no
effect by default). Feel free to accept the patch or ignore it.

[For anyone who might be interested in a version that also resizes a one-window
frame: http://www.emacswiki.org/emacs/face-remap%2b.el.]

[-- Attachment #2: face-remap-2009-06-22.patch --]
[-- Type: application/octet-stream, Size: 3126 bytes --]

diff -c -w face-remap.el face-remap-patched-2009-06-22.el
*** face-remap.el	Mon Jun 22 10:06:24 2009
--- face-remap-patched-2009-06-22.el	Mon Jun 22 11:41:02 2009
***************
*** 191,196 ****
--- 191,207 ----
    :type 'number
    :version "23.1")
  
+ (defcustom text-scale-resize-window t
+   "Non-nil means text scaling resizes the window accordingly.
+ For example, if you use `C-x C--' (`text-scale-decrease')' to make the
+ text smaller, then the window is made smaller by a similar factor."
+   :type '(choice
+           (const :tag "Do not resize window when scale text"  nil)
+           (const :tag "Resize window when scale text"         t)
+           (const :tag "Resize only horizontally"              horizontally)
+           (const :tag "Resize only vertically"                vertically))
+   :group 'display)
+ 
  ;; current remapping cookie for text-scale-mode
  (defvar text-scale-mode-remapping nil)
  (make-variable-buffer-local 'text-scale-mode-remapping)
***************
*** 237,247 ****
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! will remove any scaling currently active."
    (interactive "p")
    (setq text-scale-mode-amount
  	(if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!   (text-scale-mode (if (zerop text-scale-mode-amount) -1 1)))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)
--- 248,277 ----
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! removes any scaling currently active.
! 
! If option `text-scale-resize-window' is non-nil, then resize the
! selected window accordingly, so as to keep roughly the same text
! visible in the window.  See option `text-scale-resize-window' for the
! possible behaviors."
    (interactive "p")
+   (let* ((oamount       (if text-scale-mode text-scale-mode-amount 0))
+          (scale-factor  (expt text-scale-mode-step (if (= inc 0) (- oamount) inc)))
+          (edges         (window-edges))
+          (owidth        (- (nth 2 edges) (nth 0 edges)))
+          (oheight       (- (nth 3 edges) (nth 1 edges))))
      (setq text-scale-mode-amount
            (if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!     (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))
!     (when text-scale-resize-window
!       (unless (eq text-scale-resize-window 'vertically)
!         (condition-case nil
!             (enlarge-window-horizontally (round (- (* owidth scale-factor) owidth)))
!           (error nil)))
!       (unless (eq text-scale-resize-window 'horizontally)
!         (condition-case nil
!             (enlarge-window (round (- (* oheight scale-factor) oheight)))
!           (error nil))))))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)

Diff finished.  Mon Jun 22 11:42:00 2009

^ permalink raw reply	[flat|nested] 20+ messages in thread
* face-remap.el patch to resize window
@ 2009-06-29 22:10 Drew Adams
  0 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2009-06-29 22:10 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

Resending.


-----Original Message-----
From: Drew Adams Sent: Monday, June 22, 2009 1:40 PM

Commands `text-scale-decrease', `text-scale-increase', and
`text-scale-adjust' (bound to `C-x C--', `C-x C-+', `C-x C-=',
and `C-x C-0') let you resize the text in the current buffer
by changing its scale factor.

When you shrink or enlarge the apparent text size this way,
however, the window takes no notice of it.  In particular,
although shrinking text can result in extra horizontal
space at the right, window commands do not see this space
as extra (available).

With this patch, user option `text-scale-resize-window' lets
you automatically resize the selected window (horizontally,
vertically, or both) when text is resized, so that the way the
window fits the buffer text remains relatively constant.
Shrinking the text in one window shrinks that window, giving
more space to adjacent windows.

Feel free to change the default value for the option (e.g. to nil, to have no
effect by default). Feel free to accept the patch or ignore it.

[For anyone who might be interested in a version that also resizes a one-window
frame: http://www.emacswiki.org/emacs/face-remap%2b.el.]

[-- Attachment #2: face-remap-2009-06-22.patch --]
[-- Type: application/octet-stream, Size: 3126 bytes --]

diff -c -w face-remap.el face-remap-patched-2009-06-22.el
*** face-remap.el	Mon Jun 22 10:06:24 2009
--- face-remap-patched-2009-06-22.el	Mon Jun 22 11:41:02 2009
***************
*** 191,196 ****
--- 191,207 ----
    :type 'number
    :version "23.1")
  
+ (defcustom text-scale-resize-window t
+   "Non-nil means text scaling resizes the window accordingly.
+ For example, if you use `C-x C--' (`text-scale-decrease')' to make the
+ text smaller, then the window is made smaller by a similar factor."
+   :type '(choice
+           (const :tag "Do not resize window when scale text"  nil)
+           (const :tag "Resize window when scale text"         t)
+           (const :tag "Resize only horizontally"              horizontally)
+           (const :tag "Resize only vertically"                vertically))
+   :group 'display)
+ 
  ;; current remapping cookie for text-scale-mode
  (defvar text-scale-mode-remapping nil)
  (make-variable-buffer-local 'text-scale-mode-remapping)
***************
*** 237,247 ****
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! will remove any scaling currently active."
    (interactive "p")
    (setq text-scale-mode-amount
  	(if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!   (text-scale-mode (if (zerop text-scale-mode-amount) -1 1)))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)
--- 248,277 ----
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! removes any scaling currently active.
! 
! If option `text-scale-resize-window' is non-nil, then resize the
! selected window accordingly, so as to keep roughly the same text
! visible in the window.  See option `text-scale-resize-window' for the
! possible behaviors."
    (interactive "p")
+   (let* ((oamount       (if text-scale-mode text-scale-mode-amount 0))
+          (scale-factor  (expt text-scale-mode-step (if (= inc 0) (- oamount) inc)))
+          (edges         (window-edges))
+          (owidth        (- (nth 2 edges) (nth 0 edges)))
+          (oheight       (- (nth 3 edges) (nth 1 edges))))
      (setq text-scale-mode-amount
            (if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!     (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))
!     (when text-scale-resize-window
!       (unless (eq text-scale-resize-window 'vertically)
!         (condition-case nil
!             (enlarge-window-horizontally (round (- (* owidth scale-factor) owidth)))
!           (error nil)))
!       (unless (eq text-scale-resize-window 'horizontally)
!         (condition-case nil
!             (enlarge-window (round (- (* oheight scale-factor) oheight)))
!           (error nil))))))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)

Diff finished.  Mon Jun 22 11:42:00 2009

^ permalink raw reply	[flat|nested] 20+ messages in thread
* face-remap.el patch to resize window
@ 2009-06-22 20:40 Drew Adams
  0 siblings, 0 replies; 20+ messages in thread
From: Drew Adams @ 2009-06-22 20:40 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

Commands `text-scale-decrease', `text-scale-increase', and
`text-scale-adjust' (bound to `C-x C--', `C-x C-+', `C-x C-=',
and `C-x C-0') let you resize the text in the current buffer
by changing its scale factor.

When you shrink or enlarge the apparent text size this way,
however, the window takes no notice of it.  In particular,
although shrinking text can result in extra horizontal
space at the right, window commands do not see this space
as extra (available).

With this patch, user option `text-scale-resize-window' lets
you automatically resize the selected window (horizontally,
vertically, or both) when text is resized, so that the way the
window fits the buffer text remains relatively constant.
Shrinking the text in one window shrinks that window, giving
more space to adjacent windows.

Feel free to change the default value for the option (e.g. to nil, to have no
effect by default). Feel free to accept the patch or ignore it.

[For anyone who might be interested in a version that also resizes a one-window
frame: http://www.emacswiki.org/emacs/face-remap%2b.el.]

[-- Attachment #2: face-remap-2009-06-22.patch --]
[-- Type: application/octet-stream, Size: 3126 bytes --]

diff -c -w face-remap.el face-remap-patched-2009-06-22.el
*** face-remap.el	Mon Jun 22 10:06:24 2009
--- face-remap-patched-2009-06-22.el	Mon Jun 22 11:41:02 2009
***************
*** 191,196 ****
--- 191,207 ----
    :type 'number
    :version "23.1")
  
+ (defcustom text-scale-resize-window t
+   "Non-nil means text scaling resizes the window accordingly.
+ For example, if you use `C-x C--' (`text-scale-decrease')' to make the
+ text smaller, then the window is made smaller by a similar factor."
+   :type '(choice
+           (const :tag "Do not resize window when scale text"  nil)
+           (const :tag "Resize window when scale text"         t)
+           (const :tag "Resize only horizontally"              horizontally)
+           (const :tag "Resize only vertically"                vertically))
+   :group 'display)
+ 
  ;; current remapping cookie for text-scale-mode
  (defvar text-scale-mode-remapping nil)
  (make-variable-buffer-local 'text-scale-mode-remapping)
***************
*** 237,247 ****
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! will remove any scaling currently active."
    (interactive "p")
    (setq text-scale-mode-amount
  	(if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!   (text-scale-mode (if (zerop text-scale-mode-amount) -1 1)))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)
--- 248,277 ----
  Each step scales the height of the default face by the variable
  `text-scale-mode-step' (a negative number of steps decreases the
  height by the same amount).  As a special case, an argument of 0
! removes any scaling currently active.
! 
! If option `text-scale-resize-window' is non-nil, then resize the
! selected window accordingly, so as to keep roughly the same text
! visible in the window.  See option `text-scale-resize-window' for the
! possible behaviors."
    (interactive "p")
+   (let* ((oamount       (if text-scale-mode text-scale-mode-amount 0))
+          (scale-factor  (expt text-scale-mode-step (if (= inc 0) (- oamount) inc)))
+          (edges         (window-edges))
+          (owidth        (- (nth 2 edges) (nth 0 edges)))
+          (oheight       (- (nth 3 edges) (nth 1 edges))))
      (setq text-scale-mode-amount
            (if (= inc 0) 0 (+ (if text-scale-mode text-scale-mode-amount 0) inc)))
!     (text-scale-mode (if (zerop text-scale-mode-amount) -1 1))
!     (when text-scale-resize-window
!       (unless (eq text-scale-resize-window 'vertically)
!         (condition-case nil
!             (enlarge-window-horizontally (round (- (* owidth scale-factor) owidth)))
!           (error nil)))
!       (unless (eq text-scale-resize-window 'horizontally)
!         (condition-case nil
!             (enlarge-window (round (- (* oheight scale-factor) oheight)))
!           (error nil))))))
  
  ;;;###autoload
  (defun text-scale-decrease (dec)

Diff finished.  Mon Jun 22 11:42:00 2009

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

end of thread, other threads:[~2009-08-11  3:45 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-10  1:04 face-remap.el patch to resize window Drew Adams
2009-08-10  3:00 ` Stefan Monnier
2009-08-10  3:27   ` Drew Adams
2009-08-10  5:04     ` Miles Bader
2009-08-10 17:00       ` Drew Adams
2009-08-10  3:34   ` Miles Bader
2009-08-10 15:01     ` Stefan Monnier
2009-08-10 16:31     ` Drew Adams
2009-08-10 16:52       ` Miles Bader
2009-08-10 16:59         ` Drew Adams
2009-08-10 17:16         ` Stefan Monnier
2009-08-10 17:00       ` Stefan Monnier
2009-08-10 17:15         ` Drew Adams
2009-08-10 17:37           ` Miles Bader
2009-08-10 21:41             ` Drew Adams
2009-08-10 18:03           ` Stefan Monnier
2009-08-10 21:50             ` Drew Adams
2009-08-11  3:45               ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2009-06-29 22:10 Drew Adams
2009-06-22 20:40 Drew Adams

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