unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* ada-mode ada-initialize-properties has an error with read-only files
@ 2007-08-10 11:17 Philippe Waroquiers
  2007-08-12  9:19 ` martin rudalics
  2007-08-14 12:31 ` martin rudalics
  0 siblings, 2 replies; 7+ messages in thread
From: Philippe Waroquiers @ 2007-08-10 11:17 UTC (permalink / raw)
  To: bug-gnu-emacs


We have encountered a small problem with the ada-mode and emacs 22.
When an Ada file is visited in emacs (in this case, I find this file
with M-x find-tag) and this Ada file is a read-only file,
we see an error message appearing in the mini-buffer/*Messages*:
File mode specification error: (buffer-read-only #<buffer flight.adb>)

After investigation, we see that this error message is produced 
by ada-initialize-properties.

To see what is going wrong, I have added various calls to (message) inside
ada-initialize-properties (see modified code below).

We get the messages "1", "2", "2.1" but not "3" .. "6"
=> so this looks to be the indication of a real problem 
as ada-initialize-properties does not finish its work.
(NB: I tested with emacs 21 the same "message" modifications. With emacs 21,
ada-initialize-properties properly does the loops. E.g. it gives
multiple messages "2.1", and then gives the messages "3" .. "6".

The consequences of this problem are not clear to me. I suspect I see
not much consequences because font-lock-mode is also enabled, and
this may "repair" the properties. 
I however highly suspect that in case font-lock-mode is not active,
that ada-mode has a bug.

I suspect that one way or another, in emacs 21, ada-initialize-properties
was called in a context where the buffer could be temporarily modified,
while with emacs 22, this is not the case anymore.
I see that ada-initialize-properties is doing things similar to font-lock.
font-lock has defined a macro save-buffer-state to save/set/restore buffer state when
setting properties. A.o., it sets and then restores inhibit-read-only
and other things. Maybe ada-mode should use this macro or a similar logic ?


(defun ada-initialize-properties ()
  "Initialize some special text properties in the whole buffer.
In particular, character constants are said to be strings, #...# are treated
as numbers instead of gnatprep comments."
  (message "1")
  (save-excursion
    (save-restriction
      (widen)
      (goto-char (point-min))
      (message "2")
      (while (re-search-forward "'.'" nil t)
        (progn
          (message "2.1")
          (add-text-properties (match-beginning 0) (match-end 0)
                               '(syntax-table ("'" . ?\")))))
      (goto-char (point-min))
      (message "3")
      (while (re-search-forward "^[ \t]*#" nil t)
	(add-text-properties (match-beginning 0) (match-end 0)
			     '(syntax-table (11 . 10))))
      (message "4")
      (set-buffer-modified-p nil)
      (message "5")

      ;;  Setting this only if font-lock is not set won't work
      ;;  if the user activates or deactivates font-lock-mode,
      ;;  but will make things faster most of the time
      (add-hook 'after-change-functions 'ada-after-change-function nil t)
      (message "6")
      )))


In GNU Emacs 22.1.1 (hppa1.1-hp-hpux11.11, Motif Version 2.1.0)
 of 2007-08-04 on bobcat
Windowing system distributor `Hewlett-Packard Company', version 11.0.600000
configured using `configure  'hppa1.1-hp-hpux11.11' '--prefix=/cm/ot/TOOL/GNU!12.43/build_G!67.IP.11/generated' '--exec-prefix=/cm/ot/TOOL/GNU!12.43/build_G!67.IP.11/generated/libexec/emacs-22.1' '--mandir=/cm/ot/TOOL/GNU!12.43/build_G!67.IP.11/generated/man' '--with-gcc=no' '--with-xpm' '--with-x11r6' '--with-x-toolkit=motif' '--x-libraries=/usr/lib/X11R6:/usr/contrib/X11R6/lib' 'build_alias=hppa1.1-hp-hpux11.11' 'host_alias=hppa1.1-hp-hpux11.11' 'target_alias=hppa1.1-hp-hpux11.11' 'CFLAGS=-g -Ae +O0 +DA1.1' 'LDFLAGS= -L/cm/ot/TOOL/GNU!12.43/build_G!67.IP.11/generated/work/emacs-22.1/xpm-3.4k/lib' 'CPPFLAGS=-I/cm/ot/TOOL/GNU!12.43/build_G!67.IP.11/generated/work/emacs-22.1/xpm-3.4k ''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  locale-coding-system: nil
  default-enable-multibyte-characters: nil


-- 
Philippe WAROQUIERS                  Eurocontrol - Central Flow Management Unit
philippe.waroquiers@eurocontrol.int  Rue de la fusee, 96
Tel: +32 2 729 97 35                 1130 Brussels
Fax: +32 2 729 90 22                 Belgium
____

This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful.

Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy.

Any views expressed in this message are those of the sender.

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

end of thread, other threads:[~2007-08-17  7:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-10 11:17 ada-mode ada-initialize-properties has an error with read-only files Philippe Waroquiers
2007-08-12  9:19 ` martin rudalics
2007-08-14 12:31 ` martin rudalics
2007-08-14 19:51   ` WAROQUIERS Philippe
2007-08-14 21:16     ` martin rudalics
2007-08-16 21:42       ` WAROQUIERS Philippe
2007-08-17  7:16         ` Stephen Leake

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