emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: table-recognize and default-major-mode


From: Tak Ota
Subject: Re: table-recognize and default-major-mode
Date: Thu, 04 Aug 2005 11:54:36 -0700 (PDT)

I briefly looked into this issue.  I tried the case Ronald reported
exactly the way he described and confirmed the reported result is
correct.  I then found a very funny thing which is outside of table.el
mechanism.  I simply instrumented table-recognize function by edebug
and tested again.

In case when the file "table" is visited the hook (table-recognize)
runs before buffer gets its content.  When table-recognize is invoked
the buffer "table" is empty.

In case when the file "table.txt" is visited the hook
(table-recognize) runs twice, first time when the buffer is empty just
like the previously describe case and the second time after the buffer
contains the actual content.

This explains the different results reported by Roland.

Why the hook is executed before the buffer content is ready is beyond
my knowledge but I believe the clue is outside of table.el code.

-Tak

Thu, 4 Aug 2005 11:27:23 -0700: "Dr Roland Winkler" <address@hidden> wrote:

> On Mon Aug 1 2005 Richard M. Stallman wrote:
> >     Up to now I had overlooked that table-recognize actually issues a
> >     message in the message area "Recognizing tables...done". This
> >     message is always issued when I load a file, suggesting that this
> >     function is always evaluated. But somehow, table-recognize has no
> >     effect.
> > 
> > I suggest that you (1) try to debug this and (2) ask the developer
> > of table.el to help.
> 
> It seems to me that the problem is not a bug of table.el. But it is
> a more general problem of how default-major-mode works.
> 
> The function table-recognize sets some text properties for some part
> of a buffer. It seems that any function which sets text properties,
> does not work properly with default-major-mode.
> 
> To be more specific, start emacs --no-init-file and load the
> following piece of code which does not require table.el.
> 
> (setq default-major-mode 'text-mode)
> (add-hook 'text-mode-hook 'foo-highlight)
> (defun foo-highlight ()
>   "Highlight all occurences of string \"foo\"."
>   (interactive)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward "foo" nil t)
>       (put-text-property (match-beginning 0) (match-end 0)
>                          'face 'highlight))
>     (set-buffer-modified-p nil)))
> 
> Then visit file "foo" or "foo.txt".
> 
> cat > foo <<EOF
> foo bar foo bar foo bar
> EOF
> cat > foo.txt <<EOF
> foo bar foo bar foo bar
> EOF
> 
> foo-highlight highlights all occurences of the string "foo" in the
> buffer visiting foo.txt, but it doesn't do that for the buffer
> visiting file foo.
> 
> Unfortunately, I am really not familiar with the emacs internals of
> how files are visited. I hope that someone else can fix this bug.
> 
> Thanks a lot,
> 
> Roland





reply via email to

[Prev in Thread] Current Thread [Next in Thread]