File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 2727; ;; Code:
2828
2929(require 'cl-lib )
30+ (require 'seq )
3031(require 'shr )
3132(require 'subr-x )
3233
@@ -140,20 +141,14 @@ Prioritize rendering as much as possible while staying within `cider-docstring-m
140141 second-attempt
141142 first-attempt)))
142143
143- (defun cider-docstring--trim (s &optional n )
144- " Returns up to the first N lines of string S ,
144+ (cl- defun cider-docstring--trim (string &optional (max-lines cider-docstring-max-lines) )
145+ " Returns up to the first MAX-LINES lines of string STRING ,
145146adding \" ...\" if trimming was necessary.
146147
147- N defaults to `cider-docstring-max-lines' ."
148- (when s
149- (let* ((n (or n cider-docstring-max-lines))
150- (lines (split-string s " \n " ))
151- (lines-length (length lines))
152- (selected-lines (cl-subseq lines 0 (min n lines-length)))
153- (result (string-join selected-lines " \n " )))
154- (if (> lines-length n)
155- (concat result " ..." )
156- result))))
148+ MAX-LINES defaults to `cider-docstring-max-lines' ."
149+ (let* ((lines (split-string string " \n " ))
150+ (string (string-join (seq-take lines max-lines) " \n " )))
151+ (concat string (when (> (length lines) max-lines) " ..." ))))
157152
158153(defun cider-docstring--format (s )
159154 " Performs formatting of S, cleaning up some common whitespace issues."
You can’t perform that action at this time.
0 commit comments