From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Guerry Subject: Re: org-bookmark.el Date: Fri, 29 Feb 2008 01:14:49 +0000 Message-ID: <871w6wftrq.fsf@bzg.ath.cx> References: <87ir0ajrol.fsf@bzg.ath.cx> <87fxvdi0kq.fsf@bzg.ath.cx> <87ejaxhxwl.fsf@shellarchive.co.uk> <87y794n9fy.fsf@bzg.ath.cx> <873arciyzp.fsf@shellarchive.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JUtpu-0002qw-Vi for emacs-orgmode@gnu.org; Thu, 28 Feb 2008 20:14:55 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JUtpt-0002qk-BW for emacs-orgmode@gnu.org; Thu, 28 Feb 2008 20:14:54 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JUtpt-0002qh-83 for emacs-orgmode@gnu.org; Thu, 28 Feb 2008 20:14:53 -0500 Received: from ug-out-1314.google.com ([66.249.92.172]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JUtps-0000yT-UQ for emacs-orgmode@gnu.org; Thu, 28 Feb 2008 20:14:53 -0500 Received: by ug-out-1314.google.com with SMTP id a2so38593ugf.48 for ; Thu, 28 Feb 2008 17:14:52 -0800 (PST) In-Reply-To: <873arciyzp.fsf@shellarchive.co.uk> (Phil Jackson's message of "Thu, 28 Feb 2008 20:53:46 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Phil Jackson Cc: Tokuya Kameshima , emacs-orgmode@gnu.org --=-=-= Phil Jackson writes: > Bastien writes: > >>> I don't think it needs to go into org.el does it? When org-bookmark gets >>> it's turn upon `org-store-link' it should check a variable called, for >>> example, `org-bookmark-check-bookmarks-first' and then if that's non-nil >>> check major-mode and act accordingly. This will keep `org-store-link' >>> nice and clean. > >> Of course, you're right. >> >> But I doubt whether `org-bookmark-check-bookmarks-first' would be >> useful here. People using `org-bookmark.el' are likely to use it in >> dired-mode and in buffer visiting files as well. Actually, I would >> use it just for that (not really for creating links from the bookmarks >> list.) > > I don't think that just through the act of loading a module the > unrelated default behaviour should change. I would put a vote in for > this behaviour to be off by default (but then I don't use bookmarks). I've made some changes on org-bookmark.el in the git repository. I added three options: org-bookmark-in-dired nil org-bookmark-when-visiting-a-file nil org-bookmark-use-first-bookmark nil By default, the behavior is the same than what Tokuya proposed. But turning the options on, it will let you use org-bookmark to link to a bookmark if the buffer is visiting a bookmarked file. Tokuya, this is quite a big change on your original code. Please feel free to tell me you prefer to keep your original code in the CONTRIB/ section instead of this one. Thanks, --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-bookmark.el Content-Transfer-Encoding: 8bit ;;; org-bookmark.el - Support for links to bookmark ;; Copyright (C) 2008 Free Software Foundation, Inc. ;; ;; Author: Tokuya Kameshima ;; Version: 1.0 ;; Keywords: outlines, hypermedia, calendar, wp ;; ;; This file is not part of GNU Emacs. ;; ;; Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'org) (require 'bookmark) (defgroup org-bookmark nil "Options concerning the bookmark link." :tag "Org Startup" :group 'org-link) (defcustom org-bookmark-in-dired nil "Use org-bookmark in dired." :group 'org-bookmark :type 'boolean) (defcustom org-bookmark-when-visiting-a-file nil "Use org-bookmark in any buffer visiting a file." :group 'org-bookmark :type 'boolean) (defcustom org-bookmark-use-first-bookmark nil "If several bookmarks links to the buffer, take the first one. Otherwise prompt the user for the right bookmark to use." :group 'org-bookmark :type 'boolean) (org-add-link-type "bookmark" 'org-bookmark-open) (add-hook 'org-store-link-functions 'org-bookmark-store-link) (defun org-bookmark-open (bookmark) "Visit the bookmark BOOKMARK." (bookmark-jump bookmark)) (defun org-bookmark-store-link () "Store a link to the current line's bookmark in bookmark list." (let (file bookmark) (cond ((and org-bookmark-in-dired (eq major-mode 'dired-mode)) (setq file (abbreviate-file-name (dired-get-filename)))) ((and org-bookmark-when-visiting-a-file (buffer-file-name (buffer-base-buffer))) (setq file (abbreviate-file-name (buffer-file-name (buffer-base-buffer)))))) (if (not file) (when (eq major-mode 'bookmark-bmenu-mode) (setq bookmark (bookmark-bmenu-bookmark))) (when (and (setq bmks (mapcar (lambda(bmk) (if (equal file (abbreviate-file-name (cdr (assoc 'filename (cadr bmk))))) (car bmk))) bookmark-alist)) (setq bmks (delete nil bmks))) (setq bookmark (if (or (eq 1 (length bmks)) org-bookmark-use-first-bookmark) (car bmks) (completing-read "Bookmark: " bmks nil t nil nil (car bmks)))))) (if bookmark (org-store-link-props :link (org-make-link "bookmark:" bookmark) :description bookmark)))) (provide 'org-bookmark) ;;; org-bookmark.el ends here --=-=-= -- Bastien --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--