unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* trouble turning off visual line mode
@ 2009-09-06 21:55 Allan Gottlieb
  2009-09-07 15:08 ` Allan Gottlieb
  0 siblings, 1 reply; 4+ messages in thread
From: Allan Gottlieb @ 2009-09-06 21:55 UTC (permalink / raw)
  To: help-gnu-emacs

I have the following function in my .emacs

;; Want auto-fill and not visual-line-mode
;; Define the function here; add to hook via customize
(defun ajg-html-visual-off-fill-on ()
  "For html, turn OFF visual-line-mode and turn-ON auto fill"
  (message "ckpt 1")
  (visual-line-mode -1)
  (message "ckpt 2")
  (auto-fill-mode 1)
  (message "ckpt 3")
  )

I have it put in the html-mode-hook via

(custom-set-variables
...
 '(html-mode-hook (quote (ajg-alter-electric-html-tag ajg-html-visual-off-fill-on)))
...
)

Yet when I visit an html file
auto-fill-mode is turned on as expected but
visual-line-mode is *not* turned off.

Any help would be appreciated.
thanks,
allan

PS.

All three ckpt msgs are in *Message*, with nothing in between
The mode line shows wrap and fill




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

* Re: trouble turning off visual line mode
       [not found] <mailman.6141.1252274152.2239.help-gnu-emacs@gnu.org>
@ 2009-09-07  5:13 ` Xah Lee
  2009-09-07 14:45   ` Allan Gottlieb
  0 siblings, 1 reply; 4+ messages in thread
From: Xah Lee @ 2009-09-07  5:13 UTC (permalink / raw)
  To: help-gnu-emacs

On Sep 6, 2:55 pm, Allan Gottlieb <gottl...@nyu.edu> wrote:
> I have the following function in my .emacs
>
> ;; Want auto-fill and not visual-line-mode
> ;; Define the function here; add to hook via customize
> (defun ajg-html-visual-off-fill-on ()
>   "For html, turn OFF visual-line-mode and turn-ON auto fill"
>   (message "ckpt 1")
>   (visual-line-mode -1)
>   (message "ckpt 2")
>   (auto-fill-mode 1)
>   (message "ckpt 3")
>   )
>
> I have it put in the html-mode-hook via
>
> (custom-set-variables
> ...
>  '(html-mode-hook (quote (ajg-alter-electric-html-tag ajg-html-visual-off-fill-on)))
> ...
> )
>
> Yet when I visit an html file
> auto-fill-mode is turned on as expected but
> visual-line-mode is *not* turned off.

for minor modes, the convention is 1 is on and 0 is off.

i got a lesson of that recently from emacs devers too. it's in elisp
manual under the minor mode section too.

 Xah


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

* Re: trouble turning off visual line mode
  2009-09-07  5:13 ` Xah Lee
@ 2009-09-07 14:45   ` Allan Gottlieb
  0 siblings, 0 replies; 4+ messages in thread
From: Allan Gottlieb @ 2009-09-07 14:45 UTC (permalink / raw)
  To: help-gnu-emacs

At Sun, 06 Sep 2009 22:13:42 -0700 (PDT) Xah Lee <xahlee@gmail.com> wrote:

> On Sep 6, 2:55 pm, Allan Gottlieb <gottl...@nyu.edu> wrote:
>> I have the following function in my .emacs
>>
>> ;; Want auto-fill and not visual-line-mode
>> ;; Define the function here; add to hook via customize
>> (defun ajg-html-visual-off-fill-on ()
>>   "For html, turn OFF visual-line-mode and turn-ON auto fill"
>>   (message "ckpt 1")
>>   (visual-line-mode -1)
>>   (message "ckpt 2")
>>   (auto-fill-mode 1)
>>   (message "ckpt 3")
>>   )
>>
>> I have it put in the html-mode-hook via
>>
>> (custom-set-variables
>> ...
>>  '(html-mode-hook (quote (ajg-alter-electric-html-tag ajg-html-visual-off-fill-on)))
>> ...
>> )
>>
>> Yet when I visit an html file
>> auto-fill-mode is turned on as expected but
>> visual-line-mode is *not* turned off.
>
> for minor modes, the convention is 1 is on and 0 is off.

I believe that is wrong (see below).  Nonetheless, I tried changing -1
to 0 and there was no change.

> i got a lesson of that recently from emacs devers too. it's in elisp
> manual under the minor mode section too.

Sounds like a bad lesson.  The following is from section 23.3.1 of the
version of the elisp manual shipped with emacs 23.1.

allan

   * Define a command whose name is the same as the mode variable.  Its
     job is to enable and disable the mode by setting the variable.

     The command should accept one optional argument.  If the argument
     is `nil', it should toggle the mode (turn it on if it is off, and
     off if it is on).  It should turn the mode on if the argument is a
     positive integer, the symbol `t', or a list whose CAR is one of
     those.  It should turn the mode off if the argument is a negative
     integer or zero, the symbol `-', or a list whose CAR is a negative
     integer or zero.  The meaning of other arguments is not specified.

     Here is an example taken from the definition of
     `transient-mark-mode'.  It shows the use of `transient-mark-mode'
     as a variable that enables or disables the mode's behavior, and
     also shows the proper way to toggle, enable or disable the minor
     mode based on the raw prefix argument value.

          (setq transient-mark-mode
                (if (null arg) (not transient-mark-mode)
                  (> (prefix-numeric-value arg) 0)))




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

* Re: trouble turning off visual line mode
  2009-09-06 21:55 trouble turning off visual line mode Allan Gottlieb
@ 2009-09-07 15:08 ` Allan Gottlieb
  0 siblings, 0 replies; 4+ messages in thread
From: Allan Gottlieb @ 2009-09-07 15:08 UTC (permalink / raw)
  To: help-gnu-emacs

At Sun, 06 Sep 2009 17:55:38 -0400 Allan Gottlieb <gottlieb@nyu.edu> wrote:

> I have the following function in my .emacs
>
> ;; Want auto-fill and not visual-line-mode
> ;; Define the function here; add to hook via customize
> (defun ajg-html-visual-off-fill-on ()
>   "For html, turn OFF visual-line-mode and turn-ON auto fill"
>   (message "ckpt 1")
>   (visual-line-mode -1)
>   (message "ckpt 2")
>   (auto-fill-mode 1)
>   (message "ckpt 3")
>   )
>
> I have it put in the html-mode-hook via
>
> (custom-set-variables
> ...
>  '(html-mode-hook (quote (ajg-alter-electric-html-tag ajg-html-visual-off-fill-on)))
> ...
> )
>
> Yet when I visit an html file
> auto-fill-mode is turned on as expected but
> visual-line-mode is *not* turned off.
>
> Any help would be appreciated.
> thanks,
> allan
>
> PS.
>
> All three ckpt msgs are in *Message*, with nothing in between
> The mode line shows wrap and fill

I am pretty sure this is a bug.  It involves hooks but does not involve
custom-set-variable as I had erroneously suggested above.

Have /tmp/fun.el contain
(defun visual-off-fill-on ()
  "For html, turn OFF visual-line-mode and turn-ON auto fill"
  (visual-line-mode 0)
  (auto-fill-mode 1))

Start emacs -Q
(load-file "/tmp/fun.el")
(global-visual-line-mode)
(add-hook 'html-mode-hook 'visual-off-fill-on)
(find-file "/tmp/x.html")   ; non-existent file

mode line shows fill as expected, but also shows wrap, the bug.

However, if one does instead

Start emacs -Q
(load-file "/tmp/fun.el")
(global-visual-line-mode)
(find-file "/tmp/x.html")   ; non-existent file
(visual-off-fill-on)

then all is well (mode line shows fill and not wrap).

I plan on filing a bug report.

allan




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

end of thread, other threads:[~2009-09-07 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-06 21:55 trouble turning off visual line mode Allan Gottlieb
2009-09-07 15:08 ` Allan Gottlieb
     [not found] <mailman.6141.1252274152.2239.help-gnu-emacs@gnu.org>
2009-09-07  5:13 ` Xah Lee
2009-09-07 14:45   ` Allan Gottlieb

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