all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman@gmail.com>
To: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Small patch for rng-valid.el
Date: Sat, 2 May 2009 01:14:56 +0200	[thread overview]
Message-ID: <e01d8a50905011614u6df22ef1v6111738aab2a1beb@mail.gmail.com> (raw)

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

I just realized that I have a small patch for rng-valid.el that is
needed for it to work with nXhtml/MuMaMo. I would be glad if we could
apply it now and I do not believe it can break anything. I have
attached the patch.

Several people have had problems with this, see

   https://bugs.launchpad.net/nxhtml/+bug/354363

[-- Attachment #2: rng-valid.el.diff --]
[-- Type: application/octet-stream, Size: 7196 bytes --]

Index: rng-valid.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/nxml/rng-valid.el,v
retrieving revision 1.6
diff -c -b -r1.6 rng-valid.el
*** rng-valid.el	6 May 2008 04:25:58 -0000	1.6
--- rng-valid.el	27 May 2008 23:23:24 -0000
***************
*** 520,527 ****
  			    (t (rng-set-initial-state))))))))))
  
  
  (defun rng-do-some-validation-1 (&optional continue-p-function)
!   (let ((limit (+ rng-validate-up-to-date-end
  		  rng-validate-chunk-size))
  	(remove-start rng-validate-up-to-date-end)
  	(next-cache-point (+ (point) rng-state-cache-distance))
--- 520,558 ----
  			    (t (rng-set-initial-state))))))))))
  
  
+ (defvar rng-get-major-mode-chunk-function nil
+   "Function to use to get major mode chunk.
+ It should take one argument, the point where to get the major mode chunk.
+ 
+ This is to be set by multiple major mode frame works, like
+ mumamo.
+ 
+ See also `rng-valid-nxml-major-mode-chunk-function' and
+ `rng-end-major-mode-chunk-function'. Note that all three
+ variables must be set.")
+ (make-variable-buffer-local 'rng-get-major-mode-chunk-function)
+ (put 'rng-get-major-mode-chunk-function 'permanent-local t)
+ 
+ (defvar rng-valid-nxml-major-mode-chunk-function nil
+   "Function to use to check if nxml can parse major mode chunk.
+ It should take one argument, the chunk.
+ 
+ For more info see also `rng-get-major-mode-chunk-function'.")
+ (make-variable-buffer-local 'rng-valid-nxml-major-mode-chunk-function)
+ (put 'rng-valid-nxml-major-mode-chunk-function 'permanent-local t)
+ 
+ (defvar rng-end-major-mode-chunk-function nil
+   "Function to use to get the end of a major mode chunk.
+ It should take one argument, the chunk.
+ 
+ For more info see also `rng-get-major-mode-chunk-function'.")
+ (make-variable-buffer-local 'rng-end-major-mode-chunk-function)
+ (put 'rng-end-major-mode-chunk-function 'permanent-local t)
+ 
  (defun rng-do-some-validation-1 (&optional continue-p-function)
!   (let (major-mode-chunk
!         end-major-mode-chunk
!         (limit (+ rng-validate-up-to-date-end
  		  rng-validate-chunk-size))
  	(remove-start rng-validate-up-to-date-end)
  	(next-cache-point (+ (point) rng-state-cache-distance))
***************
*** 536,543 ****
  	xmltok-attributes
  	xmltok-namespace-attributes
  	xmltok-dependent-regions
! 	xmltok-errors)
!     (when (= (point) 1)
        (let ((regions (xmltok-forward-prolog)))
  	(rng-clear-overlays 1 (point))
  	(while regions
--- 567,576 ----
  	xmltok-attributes
  	xmltok-namespace-attributes
  	xmltok-dependent-regions
! 	xmltok-errors
!         )
!     ;;(message ">>>>>>>>> here -1, p=%s" (point)) ;;(sit-for 4)
!     (when (and continue (= (point) 1))
        (let ((regions (xmltok-forward-prolog)))
  	(rng-clear-overlays 1 (point))
  	(while regions
***************
*** 549,558 ****
  	(rng-clear-conditional-region))
        (setq rng-dtd xmltok-dtd))
      (while continue
!       (setq have-remaining-chars (rng-forward))
        (let ((pos (point)))
  	(setq continue
  	      (and have-remaining-chars
  		   (or (< pos limit)
  		       (and continue-p-function
  			    (funcall continue-p-function)
--- 582,631 ----
  	(rng-clear-conditional-region))
        (setq rng-dtd xmltok-dtd))
      (while continue
!       ;; If mumamo (or something similar) is used then jump over parts
!       ;; that can not be parsed by nxml-mode.
!       (when (and rng-get-major-mode-chunk-function
!                  rng-valid-nxml-major-mode-chunk-function
!                  rng-end-major-mode-chunk-function)
!         (let ((here (point))
!               next-non-space-pos)
!           (skip-chars-forward " \t\r\n")
!           (setq next-non-space-pos (point))
!           (goto-char here)
!           ;;(message "here when, p=%s emmc=%s non-space=%s" (point) end-major-mode-chunk next-non-space-pos) ;;(sit-for 4)
!           (unless (and end-major-mode-chunk
!                        ;; Remaining chars in this chunk?
!                        (< next-non-space-pos end-major-mode-chunk))
!             (setq end-major-mode-chunk nil)
!             (setq major-mode-chunk (funcall rng-get-major-mode-chunk-function next-non-space-pos))
!             (while (and major-mode-chunk
!                         (not (funcall rng-valid-nxml-major-mode-chunk-function major-mode-chunk))
!                         (< next-non-space-pos (point-max)))
!               (let ((end-pos (funcall rng-end-major-mode-chunk-function major-mode-chunk)))
!                 (goto-char (+ end-pos 0))
!                 (setq major-mode-chunk (funcall rng-get-major-mode-chunk-function (point)))
!                 ;;(message "---> here 3, point=%s, ep=%s, mm-chunk=%s" (point) end-pos major-mode-chunk)
!                 )
!               (setq next-non-space-pos (point))))
!           ;; Stop parsing if we do not have a chunk here yet.
!           (setq continue (and major-mode-chunk
!                               (funcall rng-valid-nxml-major-mode-chunk-function major-mode-chunk)))
!           (when continue
!             ;;(message "  continue=t")
!             (setq end-major-mode-chunk (funcall rng-end-major-mode-chunk-function major-mode-chunk)))))
! 
!       (when continue
!         ;;(message "*** here remain, p=%s" (point))
!         (setq have-remaining-chars (rng-forward end-major-mode-chunk))
!         ;;(message "*** here remain b, p=%s" (point))
          (let ((pos (point)))
+           (when end-major-mode-chunk
+             ;; Fix-me: Seems like we need a new initialization (or why
+             ;; do we otherwise hang without this?)
+             (and (> limit end-major-mode-chunk) (setq limit end-major-mode-chunk)))
            (setq continue
                  (and have-remaining-chars
+                      continue
                       (or (< pos limit)
                           (and continue-p-function
                                (funcall continue-p-function)
***************
*** 582,587 ****
--- 655,661 ----
                   (setq next-cache-point (+ pos rng-state-cache-distance))
                   (rng-clear-cached-state remove-start pos)
                   (when have-remaining-chars
+                    ;;(message "rng-cach-state (1- %s)" pos)
                     (rng-cache-state (1- pos)))
                   (setq remove-start pos)
                   (unless continue
***************
*** 603,609 ****
  			  (rng-clear-conditional-region))
  			 ((< rng-conditional-up-to-date-start pos)
  			  (set-marker rng-conditional-up-to-date-start
! 				      pos)))))))))
      have-remaining-chars))
      
  (defun rng-clear-conditional-region ()
--- 677,683 ----
                              (rng-clear-conditional-region))
                             ((< rng-conditional-up-to-date-start pos)
                              (set-marker rng-conditional-up-to-date-start
!                                         pos))))))))))
      have-remaining-chars))
  
  (defun rng-clear-conditional-region ()

             reply	other threads:[~2009-05-01 23:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01 23:14 Lennart Borgman [this message]
2009-05-02  1:37 ` Small patch for rng-valid.el Stefan Monnier
2009-05-02  1:41   ` Lennart Borgman
2009-05-02 11:46     ` Davi Leal
2009-05-02 11:50       ` Lennart Borgman
2009-05-10  2:02 ` Lennart Borgman
2009-05-13  9:33   ` Lennart Borgman
2009-05-13 14:34     ` Jason Rumney
2009-05-13 20:55       ` Lennart Borgman
2009-05-13 22:53         ` Jason Rumney
2009-05-13 22:59           ` Lennart Borgman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e01d8a50905011614u6df22ef1v6111738aab2a1beb@mail.gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.