summaryrefslogtreecommitdiff
path: root/cider-doc.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2016-05-31 15:19:09 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2016-05-31 15:38:54 -0300
commit6167e2f24746d65854120674b1da0f50c889428e (patch)
treef9fd4c9b3d066fe2393c382df9024e56aacba2b2 /cider-doc.el
parent232616579cb748d8cf9d3aa56384d6c3a18646f9 (diff)
Abbreviate file names in the doc buffer
Diffstat (limited to 'cider-doc.el')
-rw-r--r--cider-doc.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/cider-doc.el b/cider-doc.el
index 304e790c..40f0e075 100644
--- a/cider-doc.el
+++ b/cider-doc.el
@@ -365,6 +365,17 @@ Tables are marked to be ignored by line wrap."
(cider-docview-format-tables buffer) ; may contain literals, emphasis
(cider-docview-wrap-text buffer))))) ; ignores code, table blocks
+(defun cider--abbreviate-file-protocol (file-with-protocol)
+ "Abbreviate the file-path in `file:/path/to/file'."
+ (if (string-match "\\`file:\\(.*\\)" file-with-protocol)
+ (let ((file (match-string 1 file-with-protocol))
+ (proj-dir (clojure-project-dir)))
+ (if (and proj-dir
+ (file-in-directory-p file proj-dir))
+ (file-relative-name file proj-dir)
+ file))
+ file-with-protocol))
+
(defun cider-docview-render-info (buffer info)
"Emit into BUFFER formatted INFO for the Clojure or Java symbol."
(let* ((ns (nrepl-dict-get info "ns"))
@@ -449,7 +460,7 @@ Tables are marked to be ignored by line wrap."
(insert (propertize (if class java-name clj-name)
'font-lock-face 'font-lock-function-name-face)
" is defined in ")
- (insert-text-button cider-docview-file
+ (insert-text-button (cider--abbreviate-file-protocol cider-docview-file)
'follow-link t
'action (lambda (_x)
(cider-docview-source)))