Function: viper-abbreviate-string

viper-abbreviate-string is a byte-compiled function defined in viper-util.el.gz.

Signature

(viper-abbreviate-string STRING MAX-LEN PRE-STRING POST-STRING ABBREV-SIGN)

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-util.el.gz
;;; String utilities

;; If STRING is longer than MAX-LEN, truncate it and print ...... instead
;; PRE-STRING is a string to prepend to the abbrev string.
;; POST-STRING is a string to append to the abbrev string.
;; ABBREV_SIGN is a string to be inserted before POST-STRING
;; if the orig string was truncated.
(defun viper-abbreviate-string (string max-len
				     pre-string post-string abbrev-sign)
  (let (truncated-str)
    (setq truncated-str
	  (if (stringp string)
	      (substring string 0 (min max-len (length string)))))
    (cond ((null truncated-str) "")
	  ((> (length string) max-len)
	   (format "%s%s%s%s"
		   pre-string truncated-str abbrev-sign post-string))
	  (t (format "%s%s%s" pre-string truncated-str post-string)))))