From 2bb3c6522814b79723e407a5937f627846e09bc9 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 6 Mar 2006 04:50:17 +0000 Subject: [PATCH] Code simplification; improve muse-list-item-type function. * lisp/muse.el (muse-list-item-type): Disambiguate between 'dl-term and 'dl-entry, instead of just returning 'dl. (muse-forward-dl-term, muse-forward-dl-entry): Use muse-forward-list-item. (muse-forward-dl-part): Remove, merge functionality into muse-forward-list-item. (muse-forward-list-item): Add a few conditions needed for skipping nested 'dl-term and 'dl-entry items. --This line, and those below, will be ignored-- Files to commit: lisp/muse.el lisp/muse-mode.el This list might be incomplete or outdated if editing the log message was not invoked from an up-to-date changes buffer! git-archimport-id: mwolson@gnu.org--2006/muse--main--1.0--patch-46 --- ChangeLog.2006 | 28 ++++++++++++++++++++ lisp/muse.el | 83 ++++++++++++++-------------------------------------------- 2 files changed, 48 insertions(+), 63 deletions(-) diff --git a/ChangeLog.2006 b/ChangeLog.2006 index 8bc3953..34e0234 100644 --- a/ChangeLog.2006 +++ b/ChangeLog.2006 @@ -2,6 +2,34 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2006/muse--main--1.0 # +2006-03-06 04:50:17 GMT Michael Olson patch-46 + + Summary: + Code simplification; improve muse-list-item-type function. + Revision: + muse--main--1.0--patch-46 + + * lisp/muse.el (muse-list-item-type): Disambiguate between 'dl-term and + 'dl-entry, instead of just returning 'dl. + (muse-forward-dl-term, muse-forward-dl-entry): Use + muse-forward-list-item. + (muse-forward-dl-part): Remove, merge functionality into + muse-forward-list-item. + (muse-forward-list-item): Add a few conditions needed for skipping + nested 'dl-term and 'dl-entry items. + + --This line, and those below, will be ignored-- + Files to commit: + lisp/muse.el + lisp/muse-mode.el + + This list might be incomplete or outdated if editing the log + message was not invoked from an up-to-date changes buffer! + + modified files: + ChangeLog.2006 lisp/muse.el + + 2006-03-06 01:11:58 GMT Michael Olson patch-45 Summary: diff --git a/lisp/muse.el b/lisp/muse.el index 4bfde98..331c53a 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -465,7 +465,7 @@ function." (defun muse-list-item-type (str) "Determine the type of list given STR. -Returns either 'ul, 'ol, or 'dl." +Returns either 'ul, 'ol, 'dl-term, or 'dl-entry." (cond ((or (string= str "") (< (length str) 2)) nil) @@ -475,7 +475,12 @@ Returns either 'ul, 'ol, or 'dl." ((save-match-data (string-match (concat "\\`[" muse-regexp-blank "][0-9]+\\.") str)) 'ol) - (t 'dl))) + ((save-match-data + (not (string-match (concat "\\`[" muse-regexp-blank "]+::") str))) + ;; if str is not any kind of list, it will be interpreted as + ;; a dl-term + 'dl-term) + (t 'dl-entry))) (defun muse-forward-paragraph (&optional pattern) (when (get-text-property (point) 'end-list) @@ -498,7 +503,7 @@ The beginning indentation is given by INDENT." (let (status) (while (and (setq status - (muse-forward-dl-part indent)) + (muse-forward-list-item 'dl-term indent)) (string= (match-string 3) "")) (goto-char (match-end 0))) status)) @@ -510,18 +515,15 @@ The beginning indentation is given by INDENT." (let (status) (while (and (setq status - (muse-forward-dl-part indent t)) + (muse-forward-list-item 'dl-entry indent)) (not (string= (match-string 3) ""))) (goto-char (match-end 0))) status)) -(defun muse-forward-dl-part (indent &optional entry-p) - "Move forward to the next definition list part. +(defun muse-forward-list-item (type indent) + "Move forward to the next item of TYPE. Return non-nil if successful, nil otherwise. -The beginning indentation is given by INDENT. - -If ENTRY-P is non-nil, seach ahead by definition list entries. -Otherwise, search ahead by definition list terms." +The beginning indentation is given by INDENT." (let* ((list-item (format muse-list-item-regexp indent)) (empty-line (concat "^[" muse-regexp-blank "]*\n")) (indented-line (concat "^" indent "[" muse-regexp-blank "]")) @@ -533,7 +535,7 @@ Otherwise, search ahead by definition list terms." ;; see whether term begins with whitespace - if so, ;; move past it (and term - (or entry-p + (or (eq type 'dl-entry) (not (string= term ""))) (save-match-data (string-match (concat "\\`[" muse-regexp-blank "]") @@ -541,16 +543,15 @@ Otherwise, search ahead by definition list terms." (when (and (not (match-beginning 1)) (not (get-text-property (point) 'end-list)) (< (point) (point-max))) - ;; blank line encountered with no list item on the - ;; same level after it + ;; blank line encountered with no list item on the same + ;; level after it (let ((beg (point))) (forward-line 1) - (if (save-match-data - (and (looking-at indented-line) - (not (looking-at empty-line)))) - ;; found that this blank line is followed by - ;; some indentation, plus other text, so - ;; we'll keep going + (if (and (looking-at indented-line) + (not (looking-at empty-line))) + ;; found that this blank line is followed by some + ;; indentation, plus other text, so we'll keep + ;; going t (goto-char beg) nil)))))) @@ -558,50 +559,6 @@ Otherwise, search ahead by definition list terms." (>= (point) (point-max))) ;; at a list boundary, so stop nil) - ((match-string 2) - ;; move just before next occurrence of list item - (goto-char (match-beginning 1)) - (if (eq 'dl (muse-list-item-type (match-string 2))) - ;; if same type, indicate that there are more items to - ;; be parsed - t - nil)) - (t - ;; list item found, but was not a definition list - (when (match-beginning 1) - (goto-char (match-beginning 1))) - nil)))) - -(defun muse-forward-list-item (type indent) - "Move forward to the next item of TYPE. -Return non-nil if successful, nil otherwise. -The beginning indentation is given by INDENT." - (let* ((list-item (format muse-list-item-regexp indent)) - (empty-line (concat "^[" muse-regexp-blank "]*\n")) - (indented-line (concat "^" indent "[" muse-regexp-blank "]")) - (list-pattern (concat "\\(?:" empty-line "\\)?" - "\\(" list-item "\\)"))) - (while (progn - (muse-forward-paragraph list-pattern) - (when (and (not (match-beginning 1)) - (not (get-text-property (point) 'end-list)) - (< (point) (point-max))) - ;; blank line encountered with no list item on the same - ;; level after it - (let ((beg (point))) - (forward-line 1) - (if (and (looking-at indented-line) - (not (looking-at empty-line))) - ;; found that this blank line is followed by some - ;; indentation, plus other text, so we'll keep - ;; going - t - (goto-char beg) - nil))))) - (cond ((or (get-text-property (point) 'end-list) - (>= (point) (point-max))) - ;; at a list boundary, so stop - nil) ((and (match-string 2) (eq type (muse-list-item-type (match-string 2)))) ;; same type, so indicate that there are more items to be -- 2.11.4.GIT