Sfoglia il codice sorgente

Protect the attachment directory from getting a final newline.

This is a first attempt to fix a strange bug reported by Bernt Hansen,
where two attachment directories are created, one of them with a final
newline.
Carsten Dominik 16 anni fa
parent
commit
a1d457133e
3 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 6 0
      lisp/ChangeLog
  2. 1 5
      lisp/org-attach.el
  3. 1 1
      lisp/org-id.el

+ 6 - 0
lisp/ChangeLog

@@ -1,5 +1,11 @@
 2008-11-05  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-attach.el (org-attach-dir): Remove duplicate ID creation
+	code.
+
+	* org-id.el (org-id-new): Use `org-trim' to extract the uuid from
+	shell output.
+
 	* org.el (org-link-abbrev-alist): Improve customization type.
 
 	* org-attach.el (org-attach-expand-link, org-attach-expand): New

+ 1 - 5
lisp/org-attach.el

@@ -156,11 +156,7 @@ the directory and the corresponding ID will be created."
   (let ((uuid (org-id-get (point) create-if-not-exists-p)))
     (when (or uuid create-if-not-exists-p)
       (unless uuid
-	(let ((uuid-string (shell-command-to-string "uuidgen")))
-	  (setf uuid-string
-		(substring uuid-string 0 (1- (length uuid-string))))
-	  (org-entry-put (point) "ID" uuid-string)
-	  (setf uuid uuid-string)))
+	(error "ID retrieval/creation failed"))
       (let ((attach-dir (expand-file-name
 			 (format "%s/%s"
 				 (substring uuid 0 2)

+ 1 - 1
lisp/org-id.el

@@ -251,7 +251,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
     (if (equal prefix ":") (setq prefix ""))
     (cond
      ((eq org-id-method 'uuidgen)
-      (setq unique (substring (shell-command-to-string "uuidgen") 1 -1)))
+      (setq unique (org-trim (shell-command-to-string "uuidgen"))))
      ((eq org-id-method 'org)
       (let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
 	     (postfix (if org-id-include-domain