Clarify setting and getting of the slynk string elision length

This commit is contained in:
Gerard Vermeulen 2024-03-20 14:11:14 +01:00
parent c03da09ede
commit 56de583445

View File

@ -4843,20 +4843,23 @@ silent]{(describe-variable 'no-littering-var-directory)}. Listing
"(cdr (assoc 'slynk:*string-elision-length* slynk:*slynk-pprint-bindings*))"
"Slynk \"string elision length\" getter command.")
(defun slynk-command-set-sel (sel)
"Slynk SEL \"string elision length\" setter command.
SEL values must be positive integers to enable or `nil' to disable elision."
(format "(setf %s %s)" slynk-command-get-sel sel))
(defun slynk-command-set-sel (length)
"Slynk LENGTH \"string elision length\" setter command.
LENGTH values must be positive integers to enable or `nil' to disable elision."
(format "(setf %s %s)" slynk-command-get-sel length))
(defun slynk-get-sel ()
"Get the Slynk \"string-elision-length\"."
(cadr (sly-eval `(slynk:eval-and-grab-output ,slynk-command-get-sel))))
(defun slynk-set-sel (sel)
"Set the Slynk \"string-elision-length\" SEL.
SEL values must be positive integers to enable or `nil' to disable elision."
(cadr (sly-eval `(slynk:eval-and-grab-output ,(slynk-command-set-sel sel)))))
;; Most useful for Org source blocks.
(defun slynk-set-sel (length)
"Set the Slynk \"string-elision-length\" LENGTH.
LENGTH values must be positive integers to enable or `nil' to disable elision."
(cadr
(sly-eval `(slynk:eval-and-grab-output ,(slynk-command-set-sel length)))))
;; Most useful for interactive use.
(defun slynk-eval-sel-command (string)
"Evaluate the Slynk \"string-elision-length\" command STRING."
(unless (sly-connected-p)
@ -4869,14 +4872,14 @@ SEL values must be positive integers to enable or `nil' to disable elision."
(interactive)
(slynk-eval-sel-command slynk-command-get-sel))
(defun slynk-set-string-elision-length (&optional sel)
"Set the Slynk \"string-elision-length\" by evaluating SEL.
Valid SEL values are positive integers to enable or `nil' to disable elision."
(interactive "XSlynk string-elision-length (nil or sel > 0): ")
(unless (or (null sel) (and (integerp sel) (> sel 0)))
(defun slynk-set-string-elision-length (&optional length)
"Set the Slynk \"string-elision-length\" LENGTH.
Valid LENGTH values are positive integers to set or `nil' to reset."
(interactive "X\ Slink string elision length: ")
(unless (or (null length) (and (integerp length) (> length 0)))
(user-error
"Slynk `sel' must evaluate to `nil' or a positive integer (got `%S')" sel))
(slynk-eval-sel-command (slynk-command-set-sel sel))))
"Slynk `length' must be `nil' or a positive integer (got `%S')" length))
(slynk-eval-sel-command (slynk-command-set-sel length))))
#+end_src
#+caption[Script to dump a SBCL core for the Sly Common Lisp IDE]: