瀏覽代碼

Fix issue with narrowing and links in clocktables

* lisp/org-clock.el (org-clocktable-write-default): Better handling of
narrowing.

Liang Wang writes:

> After I upgrade orgmode to latest version, clock report shows link
> text literally.
>
> For example,
>
>   [[file:/home/liang/gtd/todo.org::Task...
>
> Unfortunately, in this way, I can not see what this task actually is.
> I have to temporarily disable link in clock report.
Carsten Dominik 14 年之前
父節點
當前提交
d96c998019
共有 2 個文件被更改,包括 21 次插入10 次删除
  1. 2 3
      doc/org.texi
  2. 19 7
      lisp/org-clock.el

+ 2 - 3
doc/org.texi

@@ -5923,9 +5923,8 @@ but you can specify your own function using the @code{:formatter} parameter.
 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
 :link        @r{Link the item headlines in the table to their origins.}
 :narrow      @r{An integer to limit the width of the headline column in}
-             @r{the org table.  Does not work together with @code{:link}.}
-             @r{If you write it like @samp{50!}, then the headline will also}
-             @r{be shortened in export, and will work with @code{:link}.}
+             @r{the org table.  If you write it like @samp{50!}, then the}
+             @r{headline will also be shortened in export.}
 :indent      @r{Indent each headline field according to its level.}
 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}

+ 19 - 7
lisp/org-clock.el

@@ -1895,6 +1895,7 @@ from the dynamic block defintion."
 	 (te (plist-get params :tend))
 	 (header (plist-get  params :header))
 	 (narrow (plist-get params :narrow))
+	 (link (plist-get params :link))
 	 (maxlevel (or (plist-get params :maxlevel) 3))
 	 (emph (plist-get params :emphasize))
 	 (level-p (plist-get params :level))
@@ -1902,7 +1903,7 @@ from the dynamic block defintion."
 	 (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
 	 (rm-file-column (plist-get params :one-file-with-archives))
 	 (indent (plist-get params :indent))
-	 link range-text total-time tbl level hlc formula pcol
+	 range-text total-time tbl level hlc formula pcol
 	 file-time entries entry headline
 	 recalc content narrow-cut-p)
 
@@ -1917,8 +1918,8 @@ from the dynamic block defintion."
       (when (and narrow (integerp narrow) link)
 	;; We cannot have both integer narrow and link
 	(message
-	 "Suppressing :narrow INTEGER in clocktable because :link was also given")
-	(setq narrow nil))
+	 "Using hard narrowing in clocktable to allow for links")
+	(setq narrow (intern (format "%d!" narrow))))
 
       (when narrow
 	(cond
@@ -1926,9 +1927,11 @@ from the dynamic block defintion."
 	 ((and (symbolp narrow)
 	       (string-match "\\`[0-9]+!\\'" (symbol-name narrow)))
 	  (setq narrow-cut-p t
-		narrow (string-to-number (substring (symbol-name narrow) 0 -1))))
+		narrow (string-to-number (substring (symbol-name narrow)
+						    0 -1))))
 	 (t
-	  (error "Invalid value %s of :narrow property in clock table" narrow))))
+	  (error "Invalid value %s of :narrow property in clock table"
+		 narrow))))
 
       (when block
 	;; Get the range text for the header
@@ -2008,8 +2011,17 @@ from the dynamic block defintion."
 	      (setq level (car entry)
 		    headline (nth 1 entry)
 		    hlc (if emph (or (cdr (assoc level hlchars)) "") ""))
-	      (if narrow-cut-p
-		  (setq headline (org-shorten-string headline narrow)))
+	      (when narrow-cut-p
+		(if (and (string-match (concat "\\`" org-bracket-link-regexp
+					       "\\'")
+				       headline)
+			 (match-end 3))
+		    (setq headline
+			  (format "[[%s][%s]]"
+				  (match-string 1 headline)
+				  (org-shorten-string (match-string 3 headline)
+						      narrow)))
+		  (setq headline (org-shorten-string headline narrow))))
 	      (insert-before-markers
 	       "|"                      ; start the table line
 	       (if multifile "|" "")    ; free space for file name column?