summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/info.el77
-rw-r--r--lisp/mouse.el3
-rw-r--r--lisp/subr.el19
4 files changed, 99 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 392cc9ac2fa..f0427753551 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
+2013-03-20 Juri Linkov <juri@jurta.org>
+
+ * info.el (Info-next-reference-or-link)
+ (Info-prev-reference-or-link): New functions.
+ (Info-next-reference, Info-prev-reference): Use them.
+ (Info-try-follow-nearest-node): Handle footnote navigation.
+ (Info-fontify-node): Fontify footnotes. (Bug#13989)
+
+2013-03-20 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * subr.el (posn-point, posn-string): Fix it here instead (bug#13979).
+ * mouse.el (mouse-on-link-p): Undo scroll-bar fix.
+
2013-03-20 Paul Eggert <eggert@cs.ucla.edu>
Suppress unnecessary non-ASCII chatter during build process.
@@ -15,8 +28,8 @@
* whitespace.el (whitespace-font-lock, whitespace-font-lock-mode):
Remove vars.
- (whitespace-color-on, whitespace-color-off): Use
- `font-lock-fontify-buffer' (Bug#13817).
+ (whitespace-color-on, whitespace-color-off):
+ Use `font-lock-fontify-buffer' (Bug#13817).
2013-03-19 Stefan Monnier <monnier@iro.umontreal.ca>
@@ -76,8 +89,7 @@
buffer's first char. Use `with-selected-window' instead of
`save-window-excursion' with `select-window'.
(doc-view-document->bitmap): Check the current doc-view overlay's
- display property instead the char property of the buffer's first
- char.
+ display property instead the char property of the buffer's first char.
2013-03-18 Paul Eggert <eggert@cs.ucla.edu>
diff --git a/lisp/info.el b/lisp/info.el
index 3792857d47a..3586a124c14 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -3057,6 +3057,38 @@ See `Info-scroll-down'."
(select-window (posn-window (event-start e))))
(Info-scroll-down)))
+(defun Info-next-reference-or-link (pat prop)
+ "Move point to the next pattern-based cross-reference or property-based link.
+The next cross-reference is searched using the regexp PAT, and the next link
+is searched using the text property PROP. Move point to the closest found position
+of either a cross-reference found by `re-search-forward' or a link found by
+`next-single-char-property-change'. Return the new position of point, or nil."
+ (let ((pcref (save-excursion (re-search-forward pat nil t)))
+ (plink (next-single-char-property-change (point) prop)))
+ (when (and (< plink (point-max)) (not (get-char-property plink prop)))
+ (setq plink (next-single-char-property-change plink prop)))
+ (if (< plink (point-max))
+ (if (and pcref (<= pcref plink))
+ (goto-char (or (match-beginning 1) (match-beginning 0)))
+ (goto-char plink))
+ (if pcref (goto-char (or (match-beginning 1) (match-beginning 0)))))))
+
+(defun Info-prev-reference-or-link (pat prop)
+ "Move point to the previous pattern-based cross-reference or property-based link.
+The previous cross-reference is searched using the regexp PAT, and the previous link
+is searched using the text property PROP. Move point to the closest found position
+of either a cross-reference found by `re-search-backward' or a link found by
+`previous-single-char-property-change'. Return the new position of point, or nil."
+ (let ((pcref (save-excursion (re-search-backward pat nil t)))
+ (plink (previous-single-char-property-change (point) prop)))
+ (when (and (> plink (point-min)) (not (get-char-property plink prop)))
+ (setq plink (previous-single-char-property-change plink prop)))
+ (if (> plink (point-min))
+ (if (and pcref (>= pcref plink))
+ (goto-char (or (match-beginning 1) (match-beginning 0)))
+ (goto-char plink))
+ (if pcref (goto-char (or (match-beginning 1) (match-beginning 0)))))))
+
(defun Info-next-reference (&optional recur count)
"Move cursor to the next cross-reference or menu item in the node.
If COUNT is non-nil (interactively with a prefix arg), jump over
@@ -3071,14 +3103,13 @@ COUNT cross-references."
(old-pt (point))
(case-fold-search t))
(or (eobp) (forward-char 1))
- (or (re-search-forward pat nil t)
+ (or (Info-next-reference-or-link pat 'link)
(progn
(goto-char (point-min))
- (or (re-search-forward pat nil t)
+ (or (Info-next-reference-or-link pat 'link)
(progn
(goto-char old-pt)
(user-error "No cross references in this node")))))
- (goto-char (or (match-beginning 1) (match-beginning 0)))
(if (looking-at "\\* Menu:")
(if recur
(user-error "No cross references in this node")
@@ -3099,14 +3130,13 @@ COUNT cross-references."
(let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
(old-pt (point))
(case-fold-search t))
- (or (re-search-backward pat nil t)
+ (or (Info-prev-reference-or-link pat 'link)
(progn
(goto-char (point-max))
- (or (re-search-backward pat nil t)
+ (or (Info-prev-reference-or-link pat 'link)
(progn
(goto-char old-pt)
(user-error "No cross references in this node")))))
- (goto-char (or (match-beginning 1) (match-beginning 0)))
(if (looking-at "\\* Menu:")
(if recur
(user-error "No cross references in this node")
@@ -3840,7 +3870,25 @@ If FORK is non-nil, it is passed to `Info-goto-node'."
((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
(Info-goto-node "Top" fork))
((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
- (Info-goto-node node fork)))
+ (Info-goto-node node fork))
+ ;; footnote
+ ((setq node (Info-get-token (point) "(" "\\(([0-9]+)\\)"))
+ (let ((old-point (point)) new-point)
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t)
+ (setq new-point (if (< old-point (point))
+ ;; Go to footnote reference
+ (and (search-forward node nil t)
+ ;; Put point at beginning of link
+ (match-beginning 0))
+ ;; Go to footnote definition
+ (search-backward node nil t)))))
+ (if new-point
+ (progn
+ (goto-char new-point)
+ (setq node t))
+ (setq node nil)))))
node))
(defun Info-mouse-follow-link (click)
@@ -4896,6 +4944,21 @@ first line or header line, and for breadcrumb links.")
mouse-face highlight
help-echo "mouse-2: go to this URL"))))
+ ;; Fontify footnotes
+ (goto-char (point-min))
+ (when (and not-fontified-p (re-search-forward "^[ \t]*-+ Footnotes -+$" nil t))
+ (let ((limit (point)))
+ (goto-char (point-min))
+ (while (re-search-forward "\\(([0-9]+)\\)" nil t)
+ (add-text-properties (match-beginning 0) (match-end 0)
+ `(font-lock-face info-xref
+ link t
+ mouse-face highlight
+ help-echo
+ ,(if (< (point) limit)
+ "mouse-2: go to footnote definition"
+ "mouse-2: go to footnote reference"))))))
+
;; Hide empty lines at the end of the node.
(goto-char (point-max))
(skip-chars-backward "\n")
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 333a1cef703..0367cad87b8 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -759,8 +759,7 @@ click is the local or global binding of that event.
- Otherwise, the mouse-1 event is translated into a mouse-2 event
at the same position."
(let ((action
- (and (not (memq 'vertical-scroll-bar pos))
- (or (not (consp pos))
+ (and (or (not (consp pos))
mouse-1-click-in-non-selected-windows
(eq (selected-window) (posn-window pos)))
(or (mouse-posn-property pos 'follow-link)
diff --git a/lisp/subr.el b/lisp/subr.el
index 9a7b94208fe..4eb46ec2b01 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1044,14 +1044,17 @@ and `event-end' functions."
(nth 1 position))))
(and (symbolp area) area)))
-(defsubst posn-point (position)
+(defun posn-point (position)
"Return the buffer location in POSITION.
POSITION should be a list of the form returned by the `event-start'
-and `event-end' functions."
+and `event-end' functions.
+Returns nil if POSITION does not correspond to any buffer location (e.g.
+a click on a scroll bar)."
(or (nth 5 position)
- (if (consp (nth 1 position))
- (car (nth 1 position))
- (nth 1 position))))
+ (let ((pt (nth 1 position)))
+ (or (car-safe pt)
+ ;; Apparently this can also be `vertical-scroll-bar' (bug#13979).
+ (if (integerp pt) pt)))))
(defun posn-set-point (position)
"Move point to POSITION.
@@ -1124,12 +1127,14 @@ POSITION should be a list of the form returned by the `event-start'
and `event-end' functions."
(nth 3 position))
-(defsubst posn-string (position)
+(defun posn-string (position)
"Return the string object of POSITION.
Value is a cons (STRING . STRING-POS), or nil if not a string.
POSITION should be a list of the form returned by the `event-start'
and `event-end' functions."
- (nth 4 position))
+ (let ((x (nth 4 position)))
+ ;; Apparently this can also be `handle' or `below-handle' (bug#13979).
+ (when (consp x) x)))
(defsubst posn-image (position)
"Return the image object of POSITION.