[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] muse-visit-link-default bugs + fixes
From: |
Jim Ottaway |
Subject: |
[emacs-wiki-discuss] muse-visit-link-default bugs + fixes |
Date: |
Sun, 27 Nov 2005 12:22:59 +0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
I have found two more bugs in muse-visit-link-default, one the result
of an earlier change that I suggested.
The first is that an anchor with no link doesn't work correctly. I
have made it so that the current page is taken for the link if one has
a link such as '#link'. I am not completely certain of the
correctness of this: can it be assumed that muse-visit-link is only
called from a muse page?
The second is that finding the buffer on the basis of the page name
doesn't work: if one has a non-muse buffer with the same name
as the link, that buffer would be chosen, even if there is a buffer
that contains the page [that has, for example, been renamed uniquely
to something like 'test<notes>']. So, I have made it so that the buffer
list is searched for muse-mode and for the page name.
Regards,
--
Jim Ottaway
--- orig/lisp/muse-mode.el
+++ mod/lisp/muse-mode.el
@@ -305,6 +305,16 @@
t t)
(error "There is no valid link at point")))
+(defun muse-buffer-of-page (page)
+ "Return the buffer visiting PAGE if there is one."
+ (catch 'found
+ (dolist (b (buffer-list))
+ (when (with-current-buffer b
+ (and (or (eq major-mode 'muse-mode)
+ (derived-mode-p 'muse-mode))
+ (string= (muse-page-name) page)))
+ (throw 'found b)))))
+
(defun muse-visit-link-default (link &optional other-window)
"Visit the URL or link named by LINK.
If ANCHOR is specified, search for it after opening LINK.
@@ -318,8 +328,12 @@
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))
+ link (if (= (match-beginning 0) 0)
+ ;; If there is an anchor but no link, default
+ ;; to the current page.
+ (muse-page-name)
+ (substring link 0 (match-beginning 0)))))
+ (setq base-buffer (muse-buffer-of-page link))
(if (and base-buffer (not (buffer-file-name base-buffer)))
;; If file is temporary (no associated file), just switch to
;; the buffer
- [emacs-wiki-discuss] muse-visit-link-default bugs + fixes,
Jim Ottaway <=