From 8171f0db56d229976c9e73aa21045d3f9d6c4b93 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Thu, 29 Dec 2005 21:33:08 +0000 Subject: [PATCH] muse-publish: Use narrow-to-region to fix various bugs. * lisp/muse-publish.el (muse-publish-markup-tag): Code indent change. (muse-publish-escape-specials): Use `narrow-to-region' so that we better define the region to work with. Thanks to Sacha Chua for the advice. Also make sure that we are more careful with the result from next-single-property-change. (muse-publish-surround-text): Use narrow-to-region. Make this routine less brain-dead. (muse-publish-verse-tag): Use narrow-to-region. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-328 --- ChangeLog | 20 ++++++++++++++ lisp/muse-publish.el | 75 ++++++++++++++++++++++++++++------------------------ 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8510275..68349f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,26 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-12-29 21:33:08 GMT Michael Olson patch-328 + + Summary: + muse-publish: Use narrow-to-region to fix various bugs. + Revision: + muse--main--1.0--patch-328 + + * lisp/muse-publish.el (muse-publish-markup-tag): Code indent change. + (muse-publish-escape-specials): Use `narrow-to-region' so that we + better define the region to work with. Thanks to Sacha Chua for the + advice. Also make sure that we are more careful with the result from + next-single-property-change. + (muse-publish-surround-text): Use narrow-to-region. Make this routine + less brain-dead. + (muse-publish-verse-tag): Use narrow-to-region. + + modified files: + ChangeLog lisp/muse-publish.el + + 2005-12-29 19:49:39 GMT Michael Olson patch-327 Summary: diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index fad45fc..340558a 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -704,7 +704,8 @@ the file is published no matter what." (not (get-text-property (match-beginning 0) 'read-only))) (let ((closed-tag (match-string 3)) (start (match-beginning 0)) - (beg (point)) end attrs) + (beg (point)) + end attrs) (when (nth 2 tag-info) (let ((attrstr (match-string 2))) (while (and attrstr @@ -755,17 +756,21 @@ The following contexts exist in Muse. ((symbolp specials) (setq specials (symbol-value specials)))) (save-excursion - (goto-char beg) - (while (< (point) end) - (if (and (not ignore-read-only) (get-text-property (point) 'read-only)) - (goto-char (next-single-property-change (point) 'read-only)) - (let (repl) - (setq repl (or (assoc (char-after) specials) - (assoc (char-after) muse-publish-markup-specials))) - (if (null repl) - (forward-char 1) - (delete-char 1) - (insert-before-markers (cdr repl))))))))) + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (while (< (point) (point-max)) + (if (and (not ignore-read-only) + (get-text-property (point) 'read-only)) + (goto-char (or (next-single-property-change (point) 'read-only) + (point-max))) + (let ((repl (or (assoc (char-after) specials) + (assoc (char-after) + muse-publish-markup-specials)))) + (if (null repl) + (forward-char 1) + (delete-char 1) + (insert-before-markers (cdr repl)))))))))) (defun muse-publish-markup-word () (let* ((beg (match-beginning 2)) @@ -922,22 +927,22 @@ The following contexts exist in Muse. (defun muse-publish-surround-text (beg-tag end-tag move-func &optional indent) (unless indent (setq indent (concat "[" muse-regexp-blank "]+"))) - (let ((beg (point)) - (continue t) - end) + (let ((continue t) + beg) (while continue (muse-insert-markup beg-tag) - (setq continue (funcall move-func) - end (point-marker)) - (goto-char beg) - (while (< (point) end) - (when (looking-at indent) - (replace-match "")) - (forward-line 1)) - (goto-char end) - (skip-chars-backward (concat muse-regexp-blank "\n")) - (muse-insert-markup end-tag) - (goto-char end)))) + (setq beg (point) + continue (funcall move-func)) + (save-restriction + (narrow-to-region beg (point)) + (goto-char (point-min)) + (while (< (point) (point-max)) + (when (looking-at indent) + (replace-match "")) + (forward-line 1)) + (skip-chars-backward (concat muse-regexp-blank "\n")) + (muse-insert-markup end-tag) + (goto-char (point-max)))))) (defun muse-list-item-type (str) "Determine the type of list given STR. @@ -1246,14 +1251,16 @@ the cadr is the page name, and the cddr is the anchor." (defun muse-publish-verse-tag (beg end) (save-excursion - (goto-char beg) - (while (eq ?\ (char-syntax (char-after))) - (delete-char 1)) - (while (< (point) end) - (insert "> ") - (forward-line)) - (if (eq ?\ (char-syntax (char-before))) - (delete-char -1)))) + (save-restriction + (narrow-to-region beg end) + (goto-char (point-min)) + (while (eq ?\ (char-syntax (char-after))) + (delete-char 1)) + (while (< (point) (point-max)) + (insert "> ") + (forward-line)) + (if (eq ?\ (char-syntax (char-before))) + (delete-char -1))))) (defun muse-publish-mark-read-only (beg end) (add-text-properties beg end '(rear-nonsticky (read-only) read-only t)) -- 2.11.4.GIT