[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

url in bookmark.el



大和です.

bookmark.el(C-x r l, C-x r mなど)をお使いの方はいらっしゃいますか?
bookmark.elを用いると(ファイルシステム上の)ファイルやディレクトリ及び
infoのノードにしおりを挟むことができます.しかしurlには対応していません
でした.以下のパッチをGNU Emacs 21.0.100のbookmark.elに当てると
bookmark.elでurlを扱うことができるようになります.urlを開く場合には
emacs-w3mを用います.

emacs-w3m自身がbookmarkを持っているのでどうでも良いと言えば
どうでも良いパッチです.自分でもこのメイルを書いているうちにどう
でも良くなって来ました.このパッチを気にいった人がいたら是非教えて
下さい.bookmark.el本家(?)への統合をやります.

*** bookmark.el.old	Wed Mar  7 00:33:34 2001
--- bookmark.el	Tue Apr  3 03:06:06 2001
***************
*** 291,300 ****
    \(rear-context-string  . REAR-STR\)
    \(position . POS\)
    \(info-node . POS\)
    \(annotation . ANNOTATION\)\)
  
  So the cdr of each bookmark is an alist too.
! `info-node' is optional, by the way.")
  
  
  (defvar bookmarks-already-loaded nil)
--- 291,301 ----
    \(rear-context-string  . REAR-STR\)
    \(position . POS\)
    \(info-node . POS\)
+   \(url . URL\)
    \(annotation . ANNOTATION\)\)
  
  So the cdr of each bookmark is an alist too.
! `info-node' and `url' are optional, by the way.")
  
  
  (defvar bookmarks-already-loaded nil)
***************
*** 455,460 ****
--- 456,464 ----
    (sit-for 4)
    )
  
+ (defun bookmark-get-url (bookmark)
+   "Get the info node associated with BOOKMARK."
+   (cdr (assq 'url (bookmark-get-bookmark-record bookmark))))
  
  (defvar bookmark-history nil
    "The history list for bookmark functions.")
***************
*** 493,499 ****
      (setq bookmark-history (cons ,string bookmark-history))))
  
  
! (defun bookmark-make (name &optional annotation overwrite info-node)
    "Make a bookmark named NAME.
  Optional second arg ANNOTATION gives it an annotation.
  Optional third arg OVERWRITE means replace any existing bookmarks with
--- 497,503 ----
      (setq bookmark-history (cons ,string bookmark-history))))
  
  
! (defun bookmark-make (name &optional annotation overwrite info-node url)
    "Make a bookmark named NAME.
  Optional second arg ANNOTATION gives it an annotation.
  Optional third arg OVERWRITE means replace any existing bookmarks with
***************
*** 510,516 ****
          ;; already existing bookmark under that name and
          ;; no prefix arg means just overwrite old bookmark
          (setcdr (bookmark-get-bookmark stripped-name)
!                 (list (bookmark-make-cell annotation info-node)))
  
        ;; otherwise just cons it onto the front (either the bookmark
        ;; doesn't exist already, or there is no prefix arg.  In either
--- 514,520 ----
          ;; already existing bookmark under that name and
          ;; no prefix arg means just overwrite old bookmark
          (setcdr (bookmark-get-bookmark stripped-name)
!                 (list (bookmark-make-cell annotation info-node url)))
  
        ;; otherwise just cons it onto the front (either the bookmark
        ;; doesn't exist already, or there is no prefix arg.  In either
***************
*** 519,525 ****
        (setq bookmark-alist
              (cons
               (list stripped-name
!                    (bookmark-make-cell annotation info-node))
               bookmark-alist)))
  
      ;; Added by db
--- 523,529 ----
        (setq bookmark-alist
              (cons
               (list stripped-name
!                    (bookmark-make-cell annotation info-node url))
               bookmark-alist)))
  
      ;; Added by db
***************
*** 530,536 ****
          (bookmark-save))))
  
  
! (defun bookmark-make-cell (annotation &optional info-node)
    "Return the record part of a new bookmark, given ANNOTATION.
  Must be at the correct position in the buffer in which the bookmark is
  being set.  This might change someday.
--- 534,540 ----
          (bookmark-save))))
  
  
! (defun bookmark-make-cell (annotation &optional info-node url)
    "Return the record part of a new bookmark, given ANNOTATION.
  Must be at the correct position in the buffer in which the bookmark is
  being set.  This might change someday.
***************
*** 558,568 ****
--- 562,575 ----
      ;; Take no chances with text properties
      (set-text-properties 0 (length annotation) nil annotation)
      (set-text-properties 0 (length info-node) nil info-node)
+     (set-text-properties 0 (length url) nil url)
  
      (if annotation
          (nconc the-record (list (cons 'annotation annotation))))
      (if info-node
          (nconc the-record (list (cons 'info-node info-node))))
+     (if url
+         (nconc the-record (list (cons 'url url))))
  
      ;; Finally, return the completed record.
      the-record))
***************
*** 778,784 ****
      ;; Ask for an annotation buffer for this bookmark
      (if bookmark-use-annotations
  	(bookmark-read-annotation parg str)
!       (bookmark-make str annotation parg (bookmark-info-current-node))
        (setq bookmark-current-bookmark str)
        (bookmark-bmenu-surreptitiously-rebuild-list)
        (goto-char bookmark-current-point))))
--- 785,793 ----
      ;; Ask for an annotation buffer for this bookmark
      (if bookmark-use-annotations
  	(bookmark-read-annotation parg str)
!       (bookmark-make str annotation parg 
! 		     (bookmark-info-current-node)
! 		     (bookmark-current-url))
        (setq bookmark-current-bookmark str)
        (bookmark-bmenu-surreptitiously-rebuild-list)
        (goto-char bookmark-current-point))))
***************
*** 789,794 ****
--- 798,807 ----
    (if (eq major-mode 'Info-mode)
        Info-current-node))
  
+ (defun bookmark-current-url ()
+   (if (eq major-mode 'w3m-mode)
+       w3m-current-url))
+ 
  
  (defun bookmark-kill-line (&optional newline-too)
    "Kill from point to end of line.
***************
*** 834,840 ****
      (save-excursion
        (pop-to-buffer buf)
        (goto-char pt)
!       (bookmark-make bookmark annotation parg (bookmark-info-current-node))
        (setq bookmark-current-bookmark bookmark))
      (bookmark-bmenu-surreptitiously-rebuild-list)
      (goto-char bookmark-current-point))
--- 847,855 ----
      (save-excursion
        (pop-to-buffer buf)
        (goto-char pt)
!       (bookmark-make bookmark annotation parg 
! 		     (bookmark-info-current-node)
! 		     (bookmark-current-url))
        (setq bookmark-current-bookmark bookmark))
      (bookmark-bmenu-surreptitiously-rebuild-list)
      (goto-char bookmark-current-point))
***************
*** 970,975 ****
--- 985,992 ----
    (cond
     ;; Are we in Info?
     ((string-equal mode-name "Info") Info-current-node)
+    ;; Are we in w3m?
+    ((string-equal mode-name "w3m") w3m-current-title)
     ;; Or are we a file?
     (buffer-file-name (file-name-nondirectory buffer-file-name))
     ;; Or are we a directory?
***************
*** 1008,1019 ****
  For example, if this is a Info buffer, return the Info file's name."
    (if (eq major-mode 'Info-mode)
          Info-current-file
!     (or
!      buffer-file-name
!      (if (and (boundp 'dired-directory) dired-directory)
!          (if (stringp dired-directory)
!              dired-directory
!            (car dired-directory))))))
  
  
  (defun bookmark-maybe-load-default-file ()
--- 1025,1038 ----
  For example, if this is a Info buffer, return the Info file's name."
    (if (eq major-mode 'Info-mode)
          Info-current-file
!     (if (eq major-mode 'w3m-mode)
! 	w3m-current-url
!       (or
!        buffer-file-name
!        (if (and (boundp 'dired-directory) dired-directory)
! 	   (if (stringp dired-directory)
! 	       dired-directory
! 	     (car dired-directory)))))))
  
  
  (defun bookmark-maybe-load-default-file ()
***************
*** 1095,1103 ****
           (behind-str             (bookmark-get-rear-context-string str))
           (place                  (bookmark-get-position str))
           (info-node              (bookmark-get-info-node str))
           (orig-file              file)
           )
!     (if (setq file (bookmark-file-or-variation-thereof file))
          (save-excursion
            (save-window-excursion
              (if info-node
--- 1114,1123 ----
           (behind-str             (bookmark-get-rear-context-string str))
           (place                  (bookmark-get-position str))
           (info-node              (bookmark-get-info-node str))
+ 	 (url                    (bookmark-get-url str))
           (orig-file              file)
           )
!     (if (or url (setq file (bookmark-file-or-variation-thereof file)))
          (save-excursion
            (save-window-excursion
              (if info-node
***************
*** 1105,1114 ****
                  (progn
                    (require 'info)
                    (Info-find-node file info-node))
!               ;; Else no Info.  Can do an ordinary find-file:
!               (set-buffer (find-file-noselect file))
!               (goto-char place))
! 
              ;; Go searching forward first.  Then, if forward-str exists and
              ;; was found in the file, we can search backward for behind-str.
              ;; Rationale is that if text was inserted between the two in the
--- 1125,1136 ----
                  (progn
                    (require 'info)
                    (Info-find-node file info-node))
! 	      (if url
! 		  (w3m url)
! 		;; Else no Info nor url.  Can do an ordinary find-file:
! 		(set-buffer (find-file-noselect file))
! 		(goto-char place)))
! 	    
              ;; Go searching forward first.  Then, if forward-str exists and
              ;; was found in the file, we can search backward for behind-str.
              ;; Rationale is that if text was inserted between the two in the
***************
*** 1260,1266 ****
      (setq bookmark-alist (delq will-go bookmark-alist))
      ;; Added by db, nil bookmark-current-bookmark if the last
      ;; occurrence has been deleted
!     (or (bookmark-get-bookmark bookmark-current-bookmark)
          (setq bookmark-current-bookmark nil)))
    ;; Don't rebuild the list
    (if batch
--- 1282,1289 ----
      (setq bookmark-alist (delq will-go bookmark-alist))
      ;; Added by db, nil bookmark-current-bookmark if the last
      ;; occurrence has been deleted
!     (or (and bookmark-current-bookmark
! 	     (bookmark-get-bookmark bookmark-current-bookmark))
          (setq bookmark-current-bookmark nil)))
    ;; Don't rebuild the list
    (if batch