Skip to content

Commit 6167e2f

Browse files
committed
Abbreviate file names in the doc buffer
1 parent 2326165 commit 6167e2f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cider-doc.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,17 @@ Tables are marked to be ignored by line wrap."
365365
(cider-docview-format-tables buffer) ; may contain literals, emphasis
366366
(cider-docview-wrap-text buffer))))) ; ignores code, table blocks
367367

368+
(defun cider--abbreviate-file-protocol (file-with-protocol)
369+
"Abbreviate the file-path in `file:/path/to/file'."
370+
(if (string-match "\\`file:\\(.*\\)" file-with-protocol)
371+
(let ((file (match-string 1 file-with-protocol))
372+
(proj-dir (clojure-project-dir)))
373+
(if (and proj-dir
374+
(file-in-directory-p file proj-dir))
375+
(file-relative-name file proj-dir)
376+
file))
377+
file-with-protocol))
378+
368379
(defun cider-docview-render-info (buffer info)
369380
"Emit into BUFFER formatted INFO for the Clojure or Java symbol."
370381
(let* ((ns (nrepl-dict-get info "ns"))
@@ -449,7 +460,7 @@ Tables are marked to be ignored by line wrap."
449460
(insert (propertize (if class java-name clj-name)
450461
'font-lock-face 'font-lock-function-name-face)
451462
" is defined in ")
452-
(insert-text-button cider-docview-file
463+
(insert-text-button (cider--abbreviate-file-protocol cider-docview-file)
453464
'follow-link t
454465
'action (lambda (_x)
455466
(cider-docview-source)))

0 commit comments

Comments
 (0)