Browse Source

lisp/org-id.el: Small enhancements

* lisp/org-id.el (org-id-locations-load, org-id-add-location):
Update messages.
(org-id-hash-to-alist, org-id-paste-tracker, org-id-find-id-file):
Docstring minor enhancements.
(org-id-new): Tiny refactoring.
Bastien 4 years ago
parent
commit
78e39d58d4
1 changed files with 12 additions and 13 deletions
  1. 12 13
      lisp/org-id.el

+ 12 - 13
lisp/org-id.el

@@ -382,17 +382,15 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
 	(setq unique (org-id-uuid))))
 	(setq unique (org-id-uuid))))
      ((eq org-id-method 'org)
      ((eq org-id-method 'org)
       (let* ((etime (org-reverse-string (org-id-time-to-b36)))
       (let* ((etime (org-reverse-string (org-id-time-to-b36)))
-	     (postfix (if org-id-include-domain
-			  (progn
-			    (require 'message)
-			    (concat "@" (message-make-fqdn))))))
+	     (postfix (when org-id-include-domain
+			(require 'message)
+			(concat "@" (message-make-fqdn)))))
 	(setq unique (concat etime postfix))))
 	(setq unique (concat etime postfix))))
      ((eq org-id-method 'ts)
      ((eq org-id-method 'ts)
       (let ((ts (format-time-string org-id-ts-format))
       (let ((ts (format-time-string org-id-ts-format))
-	    (postfix (if org-id-include-domain
-			 (progn
-			   (require 'message)
-			   (concat "@" (message-make-fqdn))))))
+	    (postfix (when org-id-include-domain
+		       (require 'message)
+		       (concat "@" (message-make-fqdn)))))
 	(setq unique (concat ts postfix))))
 	(setq unique (concat ts postfix))))
      (t (error "Invalid `org-id-method'")))
      (t (error "Invalid `org-id-method'")))
     (concat prefix unique)))
     (concat prefix unique)))
@@ -591,7 +589,7 @@ When FILES is given, scan also these files."
 			(setf (car item) (expand-file-name (car item) loc))))
 			(setf (car item) (expand-file-name (car item) loc))))
 		    org-id-locations)))
 		    org-id-locations)))
 	(error
 	(error
-	 (message "Could not read org-id-values from %s.  Setting it to nil."
+	 (message "Could not read `org-id-values' from %s, setting it to nil"
 		  org-id-locations-file))))
 		  org-id-locations-file))))
     (setq org-id-files (mapcar 'car org-id-locations))
     (setq org-id-files (mapcar 'car org-id-locations))
     (setq org-id-locations (org-id-alist-to-hash org-id-locations))))
     (setq org-id-locations (org-id-alist-to-hash org-id-locations))))
@@ -600,7 +598,7 @@ When FILES is given, scan also these files."
   "Add the ID with location FILE to the database of ID locations."
   "Add the ID with location FILE to the database of ID locations."
   ;; Only if global tracking is on, and when the buffer has a file
   ;; Only if global tracking is on, and when the buffer has a file
   (unless file
   (unless file
-    (error "bug: org-id-get expects a file-visiting buffer"))
+    (error "`org-id-get' expects a file-visiting buffer"))
   (let ((afile (abbreviate-file-name file)))
   (let ((afile (abbreviate-file-name file)))
     (when (and org-id-track-globally id)
     (when (and org-id-track-globally id)
       (unless org-id-locations (org-id-locations-load))
       (unless org-id-locations (org-id-locations-load))
@@ -612,7 +610,8 @@ When FILES is given, scan also these files."
   (add-hook 'kill-emacs-hook 'org-id-locations-save))
   (add-hook 'kill-emacs-hook 'org-id-locations-save))
 
 
 (defun org-id-hash-to-alist (hash)
 (defun org-id-hash-to-alist (hash)
-  "Turn an org-id hash into an alist, so that it can be written to a file."
+  "Turn an org-id hash into an alist.
+This is to be able to write it to a file."
   (let (res x)
   (let (res x)
     (maphash
     (maphash
      (lambda (k v)
      (lambda (k v)
@@ -636,7 +635,7 @@ When FILES is given, scan also these files."
     res))
     res))
 
 
 (defun org-id-paste-tracker (txt &optional buffer-or-file)
 (defun org-id-paste-tracker (txt &optional buffer-or-file)
-  "Update any IDs in TXT and assign BUFFER-OR-FILE to them."
+  "Update any ids in TXT and assign BUFFER-OR-FILE to them."
   (when org-id-track-globally
   (when org-id-track-globally
     (save-match-data
     (save-match-data
       (setq buffer-or-file (or buffer-or-file (current-buffer)))
       (setq buffer-or-file (or buffer-or-file (current-buffer)))
@@ -655,7 +654,7 @@ When FILES is given, scan also these files."
 
 
 ;;;###autoload
 ;;;###autoload
 (defun org-id-find-id-file (id)
 (defun org-id-find-id-file (id)
-  "Query the id database for the file in which this ID is located."
+  "Query the id database for the file in which ID is located."
   (unless org-id-locations (org-id-locations-load))
   (unless org-id-locations (org-id-locations-load))
   (or (and org-id-locations
   (or (and org-id-locations
 	   (hash-table-p org-id-locations)
 	   (hash-table-p org-id-locations)