[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 4dc4d39567 2/6: Refactor cider-docstring--trim
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 4dc4d39567 2/6: Refactor cider-docstring--trim |
Date: |
Sat, 8 Jun 2024 18:59:29 -0400 (EDT) |
branch: elpa/cider
commit 4dc4d39567eb736397fec6864c4668c582762371
Author: Kato Muso <m@katomuso.io>
Commit: Kato Muso <m@katomuso.io>
Refactor cider-docstring--trim
---
cider-docstring.el | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/cider-docstring.el b/cider-docstring.el
index 6a176631fb..be8c59aa5d 100644
--- a/cider-docstring.el
+++ b/cider-docstring.el
@@ -27,6 +27,7 @@
;;; Code:
(require 'cl-lib)
+(require 'seq)
(require 'shr)
(require 'subr-x)
@@ -140,20 +141,14 @@ Prioritize rendering as much as possible while staying
within `cider-docstring-m
second-attempt
first-attempt)))
-(defun cider-docstring--trim (s &optional n)
- "Returns up to the first N lines of string S,
+(cl-defun cider-docstring--trim (string &optional (max-lines
cider-docstring-max-lines))
+ "Returns up to the first MAX-LINES lines of string STRING,
adding \"...\" if trimming was necessary.
-N defaults to `cider-docstring-max-lines'."
- (when s
- (let* ((n (or n cider-docstring-max-lines))
- (lines (split-string s "\n"))
- (lines-length (length lines))
- (selected-lines (cl-subseq lines 0 (min n lines-length)))
- (result (string-join selected-lines "\n")))
- (if (> lines-length n)
- (concat result "...")
- result))))
+MAX-LINES defaults to `cider-docstring-max-lines'."
+ (let* ((lines (split-string string "\n"))
+ (string (string-join (seq-take lines max-lines) "\n")))
+ (concat string (when (> (length lines) max-lines) "..."))))
(defun cider-docstring--format (s)
"Performs formatting of S, cleaning up some common whitespace issues."
- [nongnu] elpa/cider updated (09d3dd4041 -> 05e7570e33), ELPA Syncer, 2024/06/08
- [nongnu] elpa/cider 4dc4d39567 2/6: Refactor cider-docstring--trim,
ELPA Syncer <=
- [nongnu] elpa/cider 78cff168ac 1/6: Split cider-docstring--dumb-trim into two single-purpose functions, ELPA Syncer, 2024/06/08
- [nongnu] elpa/cider 873cbdd2e4 3/6: Tweak docstring of cider-docstring--trim, ELPA Syncer, 2024/06/08
- [nongnu] elpa/cider 61a615d051 4/6: Refactor cider-docstring--format, ELPA Syncer, 2024/06/08
- [nongnu] elpa/cider 05e7570e33 6/6: Merge pull request #3708 from katomuso/docstring-trim-format, ELPA Syncer, 2024/06/08
- [nongnu] elpa/cider fd84fad37d 5/6: Tweak docstring of cider-docstring--format, ELPA Syncer, 2024/06/08