[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
circular anchor movement, etc.
- From: Keisuke Nishida <kxn30@xxxxxxxxxxx>
- Date: Sat, 03 Mar 2001 03:05:32 -0500
西田です。
* w3m-next-anchor (w3m-previous-anchor) で、バッファの最後(最初)
まで来たら最初(最後)に移動するようにしてみた。
* 同じく、移動する度に URL を表示するようにしてみた。
* w3m-print-this-url は表示だけするようにした。w3m-save-this-url
で kill-ring に保存。(この辺は改良の余地あり)
# 触り始めるときりがない。今日はこの辺にしとこう・・
-- Kei
------------------------------------------------------------------------
--- w3m.el.~1.46.~ Fri Mar 2 03:12:09 2001
+++ w3m.el Sat Mar 3 02:56:52 2001
@@ -1306,44 +1311,60 @@
"*Print the URL of the link under point."
(interactive)
(let ((url (get-text-property (point) 'w3m-href-anchor)))
+ (message "%s" (if url
+ (w3m-expand-url url w3m-current-url)
+ "Not found"))))
+
+(defun w3m-save-this-url ()
+ (interactive)
+ (let ((url (get-text-property (point) 'w3m-href-anchor)))
(if url
- (kill-new (setq url (w3m-expand-url url w3m-current-url))))
- (message "%s" (or url "Not found."))))
+ (kill-new (w3m-expand-url url w3m-current-url)))))
+(defun w3m-goto-next-anchor ()
+ ;; move to the end of the current anchor
+ (when (get-text-property (point) 'w3m-href-anchor)
+ (goto-char (next-single-property-change (point) 'w3m-href-anchor)))
+ ;; find the next anchor
+ (let ((pos (next-single-property-change (point) 'w3m-href-anchor)))
+ (if pos (progn (goto-char pos) t) nil)))
(defun w3m-next-anchor (&optional arg)
"*Move cursor to the next anchor."
(interactive "p")
(unless arg (setq arg 1))
- (let (pos)
- (if (< arg 0)
- ;; If ARG is negative.
- (w3m-previous-anchor (- arg))
- (when (get-text-property (point) 'w3m-href-anchor)
- (goto-char (next-single-property-change (point) 'w3m-href-anchor)))
- (while (and
- (> arg 0)
- (setq pos (next-single-property-change (point) 'w3m-href-anchor)))
- (goto-char pos)
- (unless (zerop (setq arg (1- arg)))
- (goto-char (next-single-property-change (point) 'w3m-href-anchor)))))))
-
+ (if (< arg 0)
+ (w3m-previous-anchor (- arg))
+ (while (> arg 0)
+ (unless (w3m-goto-next-anchor)
+ ;; search from the beginning of the buffer
+ (goto-char (point-min))
+ (w3m-goto-next-anchor))
+ (setq arg (1- arg)))
+ (w3m-print-this-url)))
+
+(defun w3m-goto-previous-anchor ()
+ ;; move to the beginning of the current anchor
+ (when (and (not (bobp)) (get-text-property (1- (point)) 'w3m-href-anchor))
+ (goto-char (previous-single-property-change (point) 'w3m-href-anchor)))
+ ;; find the previous anchor
+ (let ((pos (previous-single-property-change (point) 'w3m-href-anchor)))
+ (if pos (progn (goto-char (previous-single-property-change
+ pos 'w3m-href-anchor)) t) nil)))
(defun w3m-previous-anchor (&optional arg)
"Move cursor to the previous anchor."
(interactive "p")
(unless arg (setq arg 1))
- (let (pos)
- (if (< arg 0)
- ;; If ARG is negative.
- (w3m-next-anchor (- arg))
- (when (get-text-property (point) 'w3m-href-anchor)
- (goto-char (previous-single-property-change (1+ (point)) 'w3m-href-anchor)))
- (while (and
- (> arg 0)
- (setq pos (previous-single-property-change (point) 'w3m-href-anchor)))
- (goto-char (previous-single-property-change pos 'w3m-href-anchor))
- (setq arg (1- arg))))))
+ (if (< arg 0)
+ (w3m-next-anchor (- arg))
+ (while (> arg 0)
+ (unless (w3m-goto-previous-anchor)
+ ;; search from the end of the buffer
+ (goto-char (point-max))
+ (w3m-goto-previous-anchor))
+ (setq arg (1- arg)))
+ (w3m-print-this-url)))
(defun w3m-view-bookmark ()