emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* bug with org-mode-hook and text-scale-set
@ 2012-03-13  6:49 Du Yanning
  2012-03-14  5:41 ` David Maus
  0 siblings, 1 reply; 10+ messages in thread
From: Du Yanning @ 2012-03-13  6:49 UTC (permalink / raw)
  To: emacs-orgmode

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

org-mode 7.8.03
emacs 23.3, 23.4, 24.0.94

steps to recreate:

emacs -q

copy the following code and paste it into the *scratch* buffer:
(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
(add-hook 'org-mode-hook '(lambda () (text-scale-set 4)))

M-x eval-buffer

then C-x C-f to open a .txt file, and then C-x C-f to open another .txt
file.
Every time a .txt is opened, the font size become larger and larger.
However, the indicator in the mode line remains +4.

[-- Attachment #2: Type: text/html, Size: 670 bytes --]

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

* Re: bug with org-mode-hook and text-scale-set
  2012-03-13  6:49 bug with org-mode-hook and text-scale-set Du Yanning
@ 2012-03-14  5:41 ` David Maus
  2012-03-14  7:46   ` Du Yanning
  0 siblings, 1 reply; 10+ messages in thread
From: David Maus @ 2012-03-14  5:41 UTC (permalink / raw)
  To: Du Yanning; +Cc: emacs-orgmode

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

Hi,

At Tue, 13 Mar 2012 14:49:41 +0800,
Du Yanning wrote:
> org-mode 7.8.03
> emacs 23.3, 23.4, 24.0.94
> 
> steps to recreate:
> 
> emacs -q
> 
> copy the following code and paste it into the *scratch* buffer:
> (add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
> (add-hook 'org-mode-hook '(lambda () (text-scale-set 4))) 
> 
> M-x eval-buffer
> 
> then C-x C-f to open a .txt file, and then C-x C-f to open another .txt file.
> Every time a .txt is opened, the font size become larger and larger.
> However, the indicator in the mode line remains +4.

I can confirm this behaviour but I don't think this is an error. The
description of `text-scale-set' reads:

C-h f text-scale-set RET

,----
| text-scale-set is an interactive autoloaded Lisp function in
| `face-remap.el'.
| 
| (text-scale-set LEVEL)
| 
| Set the scale factor of the default face in the current buffer to LEVEL.
| If LEVEL is non-zero, `text-scale-mode' is enabled, otherwise it is disabled.
| 
| LEVEL is a number of steps, with 0 representing the default size.
| Each step scales the height of the default face by the variable
|           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| `text-scale-mode-step' (a negative number decreases the height by
| the same amount).
`----

The first time `org-mode-hook' is run the height of default font is
scaled by 4 levels, i.e. the height of default font is set to a new
value. The second time `org-mode-hook' is run the height is scaled
again, this time based on the new value. And so on.

If you want to set the face height you might use:

(set-face-attribute 'default nil :height 100)

Here `100' means 100% of the font size in pt (afaik).

Best,
  -- David
-- 
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: bug with org-mode-hook and text-scale-set
  2012-03-14  5:41 ` David Maus
@ 2012-03-14  7:46   ` Du Yanning
  2012-03-29 10:45     ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Du Yanning @ 2012-03-14  7:46 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode

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

text-mode-hook and c-mode-hook do NOT have this bug.
and the org-mode-hook of orgmode shipped within emacs 23.3 does NOT have
this bug.


On Wed, Mar 14, 2012 at 1:41 PM, David Maus <dmaus@ictsoc.de> wrote:

> Hi,
>
> At Tue, 13 Mar 2012 14:49:41 +0800,
> Du Yanning wrote:
> > org-mode 7.8.03
> > emacs 23.3, 23.4, 24.0.94
> >
> > steps to recreate:
> >
> > emacs -q
> >
> > copy the following code and paste it into the *scratch* buffer:
> > (add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
> > (add-hook 'org-mode-hook '(lambda () (text-scale-set 4)))
> >
> > M-x eval-buffer
> >
> > then C-x C-f to open a .txt file, and then C-x C-f to open another .txt
> file.
> > Every time a .txt is opened, the font size become larger and larger.
> > However, the indicator in the mode line remains +4.
>
> I can confirm this behaviour but I don't think this is an error. The
> description of `text-scale-set' reads:
>
> C-h f text-scale-set RET
>
> ,----
> | text-scale-set is an interactive autoloaded Lisp function in
> | `face-remap.el'.
> |
> | (text-scale-set LEVEL)
> |
> | Set the scale factor of the default face in the current buffer to LEVEL.
> | If LEVEL is non-zero, `text-scale-mode' is enabled, otherwise it is
> disabled.
> |
> | LEVEL is a number of steps, with 0 representing the default size.
> | Each step scales the height of the default face by the variable
> |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | `text-scale-mode-step' (a negative number decreases the height by
> | the same amount).
> `----
>
> The first time `org-mode-hook' is run the height of default font is
> scaled by 4 levels, i.e. the height of default font is set to a new
> value. The second time `org-mode-hook' is run the height is scaled
> again, this time based on the new value. And so on.
>
> If you want to set the face height you might use:
>
> (set-face-attribute 'default nil :height 100)
>
> Here `100' means 100% of the font size in pt (afaik).
>
> Best,
>  -- David
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de

[-- Attachment #2: Type: text/html, Size: 2782 bytes --]

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

* Re: bug with org-mode-hook and text-scale-set
  2012-03-14  7:46   ` Du Yanning
@ 2012-03-29 10:45     ` Bastien
  2012-04-12 15:06       ` Matt Lundin
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2012-03-29 10:45 UTC (permalink / raw)
  To: Du Yanning; +Cc: David Maus, emacs-orgmode

Hi Du,

Du Yanning <duyanning@gmail.com> writes:

> text-mode-hook and c-mode-hook do NOT have this bug.
> and the org-mode-hook of orgmode shipped within emacs 23.3 does NOT
> have this bug.

This is now fixed, thanks.

The problem was that Org relied on `face-remapping-alist' to 
remap the 'default face to the 'org-default face.  Relying on 
this mechanism produces the error you reported, because the 
text-scale-set doesn't interact well with remapped faces.

I'm now relying on `buffer-face-mode' which seems to be a 
cleaner approach.

Best,

-- 
 Bastien

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

* Re: bug with org-mode-hook and text-scale-set
  2012-03-29 10:45     ` Bastien
@ 2012-04-12 15:06       ` Matt Lundin
  2012-04-12 18:28         ` Matt Lundin
  2012-04-13  5:09         ` Bastien
  0 siblings, 2 replies; 10+ messages in thread
From: Matt Lundin @ 2012-04-12 15:06 UTC (permalink / raw)
  To: Bastien; +Cc: Du Yanning, emacs-orgmode, David Maus

Bastien <bzg@gnu.org> writes:

> Du Yanning <duyanning@gmail.com> writes:
>
>> text-mode-hook and c-mode-hook do NOT have this bug.
>> and the org-mode-hook of orgmode shipped within emacs 23.3 does NOT
>> have this bug.
>
> This is now fixed, thanks.
>
> The problem was that Org relied on `face-remapping-alist' to 
> remap the 'default face to the 'org-default face.  Relying on 
> this mechanism produces the error you reported, because the 
> text-scale-set doesn't interact well with remapped faces.
>
> I'm now relying on `buffer-face-mode' which seems to be a 
> cleaner approach.

On my machine, this change causes a noticeable lag when typing in
org-mode buffers. The cursor hesitates for a bit and then lurches
forward. If I turn off buffer-face-mode the lag disappears. I'm still
figuring out how to diagnose the problem.

Best,
Matt

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

* Re: bug with org-mode-hook and text-scale-set
  2012-04-12 15:06       ` Matt Lundin
@ 2012-04-12 18:28         ` Matt Lundin
  2012-04-13  5:09           ` Bastien
  2012-04-20 13:00           ` Bastien
  2012-04-13  5:09         ` Bastien
  1 sibling, 2 replies; 10+ messages in thread
From: Matt Lundin @ 2012-04-12 18:28 UTC (permalink / raw)
  To: Bastien; +Cc: Du Yanning, emacs-orgmode, David Maus

Matt Lundin <mdl@imapmail.org> writes:

> Bastien <bzg@gnu.org> writes:
>
>> Du Yanning <duyanning@gmail.com> writes:
>>
>>> text-mode-hook and c-mode-hook do NOT have this bug.
>>> and the org-mode-hook of orgmode shipped within emacs 23.3 does NOT
>>> have this bug.
>>
>> This is now fixed, thanks.
>>
>> The problem was that Org relied on `face-remapping-alist' to 
>> remap the 'default face to the 'org-default face.  Relying on 
>> this mechanism produces the error you reported, because the 
>> text-scale-set doesn't interact well with remapped faces.
>>
>> I'm now relying on `buffer-face-mode' which seems to be a 
>> cleaner approach.
>
> On my machine, this change causes a noticeable lag when typing in
> org-mode buffers. The cursor hesitates for a bit and then lurches
> forward. If I turn off buffer-face-mode the lag disappears. I'm still
> figuring out how to diagnose the problem.

Another question: is it customary for major modes to invoke
buffer-face-mode? I was a bit confused when I first saw "BufFace" in the
mode-line, as I had not explicitly invoked the minor mode. My
understanding was that this was primarily intended as a minor mode for
user-level modifications, not for major modes to rely on (but I may very
well be mistaken).

Best,
Matt

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

* Re: bug with org-mode-hook and text-scale-set
  2012-04-12 15:06       ` Matt Lundin
  2012-04-12 18:28         ` Matt Lundin
@ 2012-04-13  5:09         ` Bastien
  1 sibling, 0 replies; 10+ messages in thread
From: Bastien @ 2012-04-13  5:09 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Du Yanning, emacs-orgmode, David Maus

Matt Lundin <mdl@imapmail.org> writes:

> On my machine, this change causes a noticeable lag when typing in
> org-mode buffers. The cursor hesitates for a bit and then lurches
> forward. If I turn off buffer-face-mode the lag disappears. I'm still
> figuring out how to diagnose the problem.

Let us know about this.  If this change triggers such problems for
several users, maybe we should just make `buffer-face-mode' optional.

-- 
 Bastien

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

* Re: bug with org-mode-hook and text-scale-set
  2012-04-12 18:28         ` Matt Lundin
@ 2012-04-13  5:09           ` Bastien
  2012-04-20 13:00           ` Bastien
  1 sibling, 0 replies; 10+ messages in thread
From: Bastien @ 2012-04-13  5:09 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Du Yanning, emacs-orgmode, David Maus

Hi Matt,

Matt Lundin <mdl@imapmail.org> writes:

> Another question: is it customary for major modes to invoke
> buffer-face-mode? I was a bit confused when I first saw "BufFace" in the
> mode-line, as I had not explicitly invoked the minor mode. My
> understanding was that this was primarily intended as a minor mode for
> user-level modifications, not for major modes to rely on (but I may very
> well be mistaken).

I don't know, I've asked the emacs-devel@ mailing list.

-- 
 Bastien

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

* Re: bug with org-mode-hook and text-scale-set
  2012-04-12 18:28         ` Matt Lundin
  2012-04-13  5:09           ` Bastien
@ 2012-04-20 13:00           ` Bastien
  2012-04-22  0:46             ` Matt Lundin
  1 sibling, 1 reply; 10+ messages in thread
From: Bastien @ 2012-04-20 13:00 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Du Yanning, emacs-orgmode, David Maus

Hi Matt,

Matt Lundin <mdl@imapmail.org> writes:

> Matt Lundin <mdl@imapmail.org> writes:
>
>> Bastien <bzg@gnu.org> writes:
>>
>>> Du Yanning <duyanning@gmail.com> writes:
>>>
>>>> text-mode-hook and c-mode-hook do NOT have this bug.
>>>> and the org-mode-hook of orgmode shipped within emacs 23.3 does NOT
>>>> have this bug.
>>>
>>> This is now fixed, thanks.
>>>
>>> The problem was that Org relied on `face-remapping-alist' to 
>>> remap the 'default face to the 'org-default face.  Relying on 
>>> this mechanism produces the error you reported, because the 
>>> text-scale-set doesn't interact well with remapped faces.
>>>
>>> I'm now relying on `buffer-face-mode' which seems to be a 
>>> cleaner approach.
>>
>> On my machine, this change causes a noticeable lag when typing in
>> org-mode buffers. The cursor hesitates for a bit and then lurches
>> forward. If I turn off buffer-face-mode the lag disappears. I'm still
>> figuring out how to diagnose the problem.
>
> Another question: is it customary for major modes to invoke
> buffer-face-mode? 

Emacs devs said using buffer-face-mode is "obnoxious".  So I
buffer-face-mode is not turned on by default anymore.  org-default is
still the face for buffer-face-mode, though.

-- 
 Bastien

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

* Re: bug with org-mode-hook and text-scale-set
  2012-04-20 13:00           ` Bastien
@ 2012-04-22  0:46             ` Matt Lundin
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Lundin @ 2012-04-22  0:46 UTC (permalink / raw)
  To: Bastien; +Cc: Du Yanning, emacs-orgmode, David Maus

Bastien <bzg@altern.org> writes:

>> Another question: is it customary for major modes to invoke
>> buffer-face-mode? 
>
> Emacs devs said using buffer-face-mode is "obnoxious".  So I
> buffer-face-mode is not turned on by default anymore.  org-default is
> still the face for buffer-face-mode, though.

Thanks, Bastien!

Best,
Matt

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

end of thread, other threads:[~2012-04-22  0:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13  6:49 bug with org-mode-hook and text-scale-set Du Yanning
2012-03-14  5:41 ` David Maus
2012-03-14  7:46   ` Du Yanning
2012-03-29 10:45     ` Bastien
2012-04-12 15:06       ` Matt Lundin
2012-04-12 18:28         ` Matt Lundin
2012-04-13  5:09           ` Bastien
2012-04-20 13:00           ` Bastien
2012-04-22  0:46             ` Matt Lundin
2012-04-13  5:09         ` Bastien

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).