X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/afe98dfa700de5cf0493e8bf95b7d894e2734e47..acaf905b1130aae80fa59d2c861ffd4c8eb75486:/lisp/org/org-id.el diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el index fcca58831d..55e826f3ae 100644 --- a/lisp/org/org-id.el +++ b/lisp/org/org-id.el @@ -1,11 +1,10 @@ ;;; org-id.el --- Global identifiers for Org-mode entries ;; -;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 2008-2012 Free Software Foundation, Inc. ;; ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 7.3 ;; ;; This file is part of GNU Emacs. ;; @@ -74,6 +73,8 @@ (require 'org) (declare-function message-make-fqdn "message" ()) +(declare-function org-pop-to-buffer-same-window + "org-compat" (&optional buffer-or-name norecord label)) ;;; Customization @@ -151,9 +152,7 @@ This variable is only relevant when `org-id-track-globally' is set." :type 'file) (defvar org-id-locations nil - "List of files with IDs in those files. -Depending on `org-id-use-hash' this can also be a hash table mapping IDs -to files.") + "List of files with IDs in those files.") (defvar org-id-files nil "List of files that contain IDs.") @@ -231,7 +230,7 @@ It returns the ID of the entry. If necessary, the ID is created." (org-refile-use-outline-path (if (caar org-refile-targets) 'file t)) (org-refile-target-verify-function nil) - (spos (org-refile-get-location "Entry: ")) + (spos (org-refile-get-location "Entry")) (pom (and spos (move-marker (make-marker) (nth 3 spos) (get-file-buffer (nth 1 spos)))))) (prog1 (org-id-get pom 'create) @@ -255,7 +254,7 @@ Move the cursor to that entry in that buffer." (let ((m (org-id-find id 'marker))) (unless m (error "Cannot find entry with ID \"%s\"" id)) - (switch-to-buffer (marker-buffer m)) + (org-pop-to-buffer-same-window (marker-buffer m)) (goto-char m) (move-marker m nil) (org-show-context))) @@ -432,7 +431,7 @@ When CHECK is given, prepare detailed information about duplicate IDs." (delq nil (mapcar (lambda (b) (with-current-buffer b - (and (org-mode-p) (buffer-file-name)))) + (and (eq major-mode 'org-mode) (buffer-file-name)))) (buffer-list))) ;; All files known to have IDs org-id-files))) @@ -519,7 +518,8 @@ When CHECK is given, prepare detailed information about duplicate IDs." (puthash id (abbreviate-file-name file) org-id-locations) (add-to-list 'org-id-files (abbreviate-file-name file)))) -(add-hook 'kill-emacs-hook 'org-id-locations-save) +(unless noninteractive + (add-hook 'kill-emacs-hook 'org-id-locations-save)) (defun org-id-hash-to-alist (hash) "Turn an org-id hash into an alist, so that it can be written to a file." @@ -600,15 +600,18 @@ optional argument MARKERP, return the position as a new marker." (defun org-id-store-link () "Store a link to the current entry, using its ID." (interactive) - (let* ((link (org-make-link "id:" (org-id-get-create))) - (case-fold-search nil) - (desc (save-excursion - (org-back-to-heading t) - (or (and (looking-at org-complex-heading-regexp) - (if (match-end 4) (match-string 4) (match-string 0))) - link)))) - (org-store-link-props :link link :description desc :type "id") - link)) + (when (and (buffer-file-name (buffer-base-buffer)) (eq major-mode 'org-mode)) + (let* ((link (org-make-link "id:" (org-id-get-create))) + (case-fold-search nil) + (desc (save-excursion + (org-back-to-heading t) + (or (and (looking-at org-complex-heading-regexp) + (if (match-end 4) + (match-string 4) + (match-string 0))) + link)))) + (org-store-link-props :link link :description desc :type "id") + link))) (defun org-id-open (id) "Go to the entry with id ID." @@ -638,7 +641,3 @@ optional argument MARKERP, return the position as a new marker." (provide 'org-id) ;;; org-id.el ends here - -;; arch-tag: e5abaca4-e16f-4b25-832a-540cfb63a712 - -