Function: hs--get-ellipsis

hs--get-ellipsis is a byte-compiled function defined in hideshow.el.gz.

Signature

(hs--get-ellipsis B E)

Documentation

Helper function for hs-make-overlay.

This returns the ellipsis string to use and its face.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
(defun hs--get-ellipsis (b e)
  "Helper function for `hs-make-overlay'.
This returns the ellipsis string to use and its face."
  (let* ((standard-display-table
          (or standard-display-table (make-display-table)))
         (d-t-ellipsis
          (display-table-slot standard-display-table 'selective-display))
         ;; Convert ellipsis vector to a propertized string
         (ellipsis
          (and (vectorp d-t-ellipsis) ; Ensure the vector is not empty
               (not (length= d-t-ellipsis 0))
               (mapconcat
                (lambda (g)
                  (apply #'propertize (char-to-string (glyph-char g))
                         (and (glyph-face g) (list 'face (glyph-face g)))))
                d-t-ellipsis)))
         (ellipsis-face (and ellipsis (get-text-property 0 'face ellipsis)))
         (apply-face (lambda (str)
                       (apply #'propertize str
                              (and ellipsis-face (list 'face ellipsis-face)))))
         (lines (when-let* (hs-display-lines-hidden
                            (l (1- (count-lines b e)))
                            (l-str (format "%d %s" l
                                           (if (= l 1) "line" "lines"))))
                  (funcall apply-face l-str)))
         (tty-strings (and hs-display-lines-hidden (not (display-graphic-p))))
         (string
          (concat (and tty-strings (funcall apply-face "["))
                  lines
                  (or ellipsis (truncate-string-ellipsis))
                  (and tty-strings (funcall apply-face "]")))))
    (if ellipsis-face
        ;; Return ELLIPSIS and LINES if ELLIPSIS has no face
        string
      ;; Otherwise propertize both with `hs-ellipsis'
      (propertize string 'face 'hs-ellipsis))))