From d0a039927d367e74d3007c2b52a742a758b7ca73 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Fri, 24 Jun 2005 00:22:12 +0000 Subject: [PATCH] Play nicely with fill, adaptive-fill, and flyspell. * muse-mode.el (muse-mode-intangible-links): New function used to determine whether links will be considered intangible. * lisp/muse-mode.el (muse-mode-link-functions) (muse-mode-handler-functions): Minor docfix. * lisp/muse-mode.el (muse-mode): Don't split long links when performing fill. Play nicely with adaptive-fill. Avoid lockup with flyspell by making links intangible by default, but this may be adjusted by use of the `muse-mode-intangible-links' function. * lisp/muse-mode.el (muse-mode-fill-nobreak-p): New function that returns nil if we should allow a fill to occur here. Keeps links from being broken up. * lisp/muse-mode.el (muse-mode-flyspell-p): New function that returns non-nil if we allow spell-checking to occur here. Keeps links from being improperly colorized. * lisp/muse-wiki.el (muse-wiki-interwiki-handle): Break up long line; no functionality change. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-76 --- ChangeLog | 33 ++++++++++++++++++++++++++++++ lisp/muse-mode.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++----- lisp/muse-wiki.el | 3 ++- 3 files changed, 91 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d9b83e..3af9aa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,39 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-06-24 00:22:12 GMT Michael Olson patch-76 + + Summary: + Play nicely with fill, adaptive-fill, and flyspell. + Revision: + muse--main--1.0--patch-76 + + * muse-mode.el (muse-mode-intangible-links): New function used to + determine whether links will be considered intangible. + + * lisp/muse-mode.el (muse-mode-link-functions) + (muse-mode-handler-functions): Minor docfix. + + * lisp/muse-mode.el (muse-mode): Don't split long links when performing + fill. Play nicely with adaptive-fill. Avoid lockup with flyspell by + making links intangible by default, but this may be adjusted by use of + the `muse-mode-intangible-links' function. + + * lisp/muse-mode.el (muse-mode-fill-nobreak-p): New function that returns + nil if we should allow a fill to occur here. Keeps links from being + broken up. + + * lisp/muse-mode.el (muse-mode-flyspell-p): New function that returns + non-nil if we allow spell-checking to occur here. Keeps links from + being improperly colorized. + + * lisp/muse-wiki.el (muse-wiki-interwiki-handle): Break up long line; no + functionality change. + + modified files: + ChangeLog lisp/muse-mode.el lisp/muse-wiki.el + + 2005-06-23 07:13:35 GMT Michael Olson patch-75 Summary: diff --git a/lisp/muse-mode.el b/lisp/muse-mode.el index a03a032..dff730f 100644 --- a/lisp/muse-mode.el +++ b/lisp/muse-mode.el @@ -75,6 +75,13 @@ See `muse-publish' for more information." (set sym value))) :group 'muse-mode) +(defcustom muse-mode-intangible-links nil + "If non-nil, use the intangible property on links. +This can cause problems with flyspell (and potentially fill-mode), +so only enable this if you don't use either of these." + :type 'boolean + :group 'muse-mode) + (defcustom muse-mode-hook nil "A hook that is run when Muse mode is entered." :type 'hook @@ -83,12 +90,12 @@ See `muse-publish' for more information." :group 'muse-mode) (defcustom muse-mode-link-functions nil - "A list of functions to recognize a link" + "A list of functions to recognize a link." :type '(repeat function) :group 'muse-mode) (defcustom muse-mode-handler-functions nil - "A list of functions to handle a link" + "A list of functions to handle a link." :type '(repeat function) :group 'muse-mode) @@ -143,18 +150,37 @@ See `muse-publish' for more information." (define-derived-mode muse-mode text-mode "Muse" "Muse is an Emacs mode for authoring and publishing documents. \\{muse-mode-map}" - ;; because we're not inheriting from normal-mode, we need to - ;; explicitly run file variables if the user wants to + ;; Since we're not inheriting from normal-mode, we need to + ;; explicitly run file variables. (condition-case err (hack-local-variables) (error (message "File local-variables error: %s" (prin1-to-string err)))) + ;; Avoid lock-up caused by use of the 'intangible' text property + ;; with flyspell. + (unless muse-mode-intangible-links + (set (make-local-variable 'inhibit-point-motion-hooks) t)) (if muse-mode-highlight-p (muse-use-font-lock)) (setq muse-current-project (muse-project-of-file)) (muse-project-set-variables) + ;; Make fill not split up links + (when (boundp 'fill-nobreak-predicate) + (make-local-variable 'fill-nobreak-predicate) + ;; Work around annoying inconsistency in fill handling between + ;; Emacs CVS and all other Emacs types. + (if (not (muse-extreg-usable-p)) + (setq fill-nobreak-predicate 'muse-mode-fill-nobreak-p) + (add-to-list 'fill-nobreak-predicate + 'muse-mode-fill-nobreak-p))) + ;; Make adaptive fill work nicely with item lists + (set (make-local-variable 'adaptive-fill-regexp) + (concat "[" muse-regexp-blank "]*\\(-+[" + muse-regexp-blank + "]*\\|[0-9]+\\.[" + muse-regexp-blank "]*\\)*")) (when (featurep 'pcomplete) - ;; if pcomplete is available, set it up! + ;; If pcomplete is available, set it up (set (make-variable-buffer-local 'pcomplete-default-completion-function) 'muse-mode-completions) (set (make-variable-buffer-local 'pcomplete-command-completion-function) @@ -162,6 +188,31 @@ See `muse-publish' for more information." (set (make-variable-buffer-local 'pcomplete-parse-arguments-function) 'muse-mode-current-word))) +(put 'muse-mode + 'flyspell-mode-predicate + 'muse-mode-flyspell-p) + +(defun muse-mode-fill-nobreak-p () + "Return nil if we should allow a fill to occur at point. +Otherwise return non-nil. + +This is used to keep long extended links from being mangled by +fill mode." + (save-excursion + (save-match-data + (and (re-search-backward "\\[\\[\\|\\]\\]" + (line-beginning-position) t) + (string= (or (match-string 0) "") + "[["))))) + +(defun muse-mode-flyspell-p () + "Return non-nil if we should allow spell-checking to occur at point. +Otherwise return nil. + +This is used to keep links from being improperly colorized by flyspell." + (save-match-data + (null (muse-link-at-point)))) + (defun muse-mode-maybe () "Maybe turn Emacs Muse mode on for this file." (let ((project (muse-project-of-file))) diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index 8b6505b..d10870a 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -85,7 +85,8 @@ this." (defun muse-wiki-interwiki-handle (url) (save-match-data (when (string-match (concat muse-wiki-interwiki-regexp "::\\(.*\\)") url) - (let ((subst (cdr (assoc (match-string 1 url) muse-wiki-interwiki-alist))) + (let ((subst (cdr (assoc (match-string 1 url) + muse-wiki-interwiki-alist))) (word (match-string 2 url))) (if (functionp subst) (funcall subst word) -- 2.11.4.GIT