From 2da3cf439dc7a65af12a1a1895b9aaa48fdd29ea Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Thu, 1 Dec 2005 01:32:29 +0000 Subject: [PATCH] muse-mode: Handle case where we visit an anchor-only link. * lisp/muse-mode.el (muse-visit-link-default): Handle case where the link consists of only an anchor. Thanks to Jim Ottaway for the patch. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-282 --- ChangeLog | 14 ++++++++++++++ lisp/muse-mode.el | 38 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87591d7..e65abdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,20 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-12-01 01:32:29 GMT Michael Olson patch-282 + + Summary: + muse-mode: Handle case where we visit an anchor-only link. + Revision: + muse--main--1.0--patch-282 + + * lisp/muse-mode.el (muse-visit-link-default): Handle case where the link + consists of only an anchor. Thanks to Jim Ottaway for the patch. + + modified files: + ChangeLog lisp/muse-mode.el + + 2005-12-01 01:08:13 GMT Michael Olson patch-281 Summary: diff --git a/lisp/muse-mode.el b/lisp/muse-mode.el index c82e32f..941f06c 100644 --- a/lisp/muse-mode.el +++ b/lisp/muse-mode.el @@ -318,22 +318,27 @@ in `muse-project-alist'." base-buffer) (when (string-match "#" link) (setq anchor (substring link (match-beginning 0)) - link (substring link 0 (match-beginning 0)))) - (setq base-buffer (get-buffer link)) - (if (and base-buffer (not (buffer-file-name base-buffer))) - ;; If file is temporary (no associated file), just switch to - ;; the buffer - (if other-window - (switch-to-buffer-other-window base-buffer) - (switch-to-buffer base-buffer)) - (let ((project (muse-project-of-file))) - (if project - (muse-project-find-file link project - (and other-window - 'find-file-other-window)) + link (if (= (match-beginning 0) 0) + ;; If there is an anchor but no link, default + ;; to the current page. + nil + (substring link 0 (match-beginning 0))))) + (when link + (setq base-buffer (get-buffer link)) + (if (and base-buffer (not (buffer-file-name base-buffer))) + ;; If file is temporary (no associated file), just switch to + ;; the buffer (if other-window - (find-file-other-window link) - (find-file link))))) + (switch-to-buffer-other-window base-buffer) + (switch-to-buffer base-buffer)) + (let ((project (muse-project-of-file))) + (if project + (muse-project-find-file link project + (and other-window + 'find-file-other-window)) + (if other-window + (find-file-other-window link) + (find-file link)))))) (when anchor (let ((pos (point))) (goto-char (point-min)) @@ -345,8 +350,7 @@ in `muse-project-alist'." (defun muse-visit-link (link &optional other-window) "Visit the URL or link named by LINK." (let ((visit-link-function - (muse-get-keyword :visit-link (cadr (muse-project-of-file)) t)) - anchor) + (muse-get-keyword :visit-link (cadr (muse-project-of-file)) t))) (if visit-link-function (funcall visit-link-function link other-window) (muse-visit-link-default link other-window)))) -- 2.11.4.GIT