threading."
(declare (indent 0) (debug thread-first))
`(internal--thread-argument nil ,@forms))
+
(defsubst hash-table-empty-p (hash-table)
"Check whether HASH-TABLE is empty (has 0 elements)."
+ (declare (side-effect-free t))
(zerop (hash-table-count hash-table)))
(defsubst hash-table-keys (hash-table)
"Return a list of keys in HASH-TABLE."
+ (declare (side-effect-free t))
(let ((keys nil))
(maphash (lambda (k _) (push k keys)) hash-table)
keys))
(defsubst hash-table-values (hash-table)
"Return a list of values in HASH-TABLE."
+ (declare (side-effect-free t))
(let ((values nil))
(maphash (lambda (_ v) (push v values)) hash-table)
values))
All sequences of whitespaces in STRING are collapsed into a
single space character, and leading/trailing whitespace is
removed."
+ (declare (important-return-value t))
(let ((blank "[[:blank:]\r\n]+"))
(string-trim (replace-regexp-in-string blank " " string t t)
blank blank)))
Wrapping is done where there is whitespace. If there are
individual words in STRING that are longer than LENGTH, the
result will have lines that are longer than LENGTH."
+ (declare (important-return-value t))
(with-temp-buffer
(insert string)
(goto-char (point-min))
When shortening strings for display purposes,
`truncate-string-to-width' is almost always a better alternative
than this function."
+ (declare (important-return-value t))
(unless (natnump length)
(signal 'wrong-type-argument (list 'natnump length)))
(if coding-system
;;;###autoload
(defun string-pixel-width (string)
"Return the width of STRING in pixels."
+ (declare (important-return-value t))
(if (zerop (length string))
0
;; Keeping a work buffer around is more efficient than creating a
if compositions are enabled, each sequence of characters composed
on display into a single grapheme cluster is treated as a single
indivisible unit."
+ (declare (side-effect-free t))
(let ((result nil)
(start 0)
comp)
(defsubst buffer-narrowed-p ()
"Return non-nil if the current buffer is narrowed."
+ (declare (side-effect-free t))
(/= (- (point-max) (point-min)) (buffer-size)))
(defmacro with-restriction (start end &rest rest)
If the optional POSIX argument is non-nil, ARGUMENT is quoted
according to POSIX shell quoting rules, regardless of the
system's shell."
-(cond
+ (cond
((and (not posix) (eq system-type 'ms-dos))
;; Quote using double quotes, but escape any existing quotes in
;; the argument with backslashes.
Note that SHA-1 is not collision resistant and should not be used
for anything security-related. See `secure-hash' for
alternatives."
+ (declare (side-effect-free t))
(secure-hash 'sha1 object start end binary))
(defun function-get (f prop &optional autoload)
If AUTOLOAD is non-nil and F is autoloaded, try to load it
in the hope that it will set PROP. If AUTOLOAD is `macro', do it only
if it's an autoloaded macro."
+ (declare (important-return-value t))
(let ((val nil))
(while (and (symbolp f)
(null (setq val (get f prop)))
are substituted with actual strings matched by the last search.
Optional FIXEDCASE, LITERAL, STRING and SUBEXP have the same
meaning as for `replace-match'."
+ (declare (side-effect-free t))
(let ((match (match-string 0 string)))
(save-match-data
(match-data--translate (- (match-beginning 0)))
repetition bounds operator `\\=\\{...\\}', or right after a `\\'.
If START is non-nil, it should be a position in REGEXP, smaller
than POS, and known to be in a subregexp context."
+ (declare (important-return-value t))
;; Here's one possible implementation, with the great benefit that it
;; reuses the regexp-matcher's own parser, so it understands all the
;; details of the syntax. A disadvantage is that it needs to match the
whitespace, use `(split-string STRING split-string-default-separators)'.
Modifies the match data; use `save-match-data' if necessary."
+ (declare (important-return-value t))
(let* ((keep-nulls (not (if separators omit-nulls t)))
(rexp (or separators split-string-default-separators))
(start 0)
Note that this is not intended to protect STRINGS from
interpretation by shells, use `shell-quote-argument' for that."
+ (declare (important-return-value t))
(let* ((sep (or separator " "))
(re (concat "[\\\"]" "\\|" (regexp-quote sep))))
(mapconcat
It understands Emacs Lisp quoting within STRING, such that
(split-string-and-unquote (combine-and-quote-strings strs)) == strs
The SEPARATOR regexp defaults to \"\\s-+\"."
+ (declare (important-return-value t))
(let ((sep (or separator "\\s-+"))
(i (string-search "\"" string)))
(if (null i)
and replace a sub-expression, e.g.
(replace-regexp-in-string \"\\\\(foo\\\\).*\\\\\\='\" \"bar\" \" foo foo\" nil nil 1)
=> \" bar foo\""
+ (declare (important-return-value t))
;; To avoid excessive consing from multiple matches in long strings,
;; don't just call `replace-match' continually. Walk down the
(defun syntax-after (pos)
"Return the raw syntax descriptor for the char after POS.
If POS is outside the buffer's accessible portion, return nil."
+ (declare (important-return-value t))
(unless (or (< pos (point-min)) (>= pos (point-max)))
(let ((st (if parse-sexp-lookup-properties
(get-char-property pos 'syntax-table))))
\"22.8beta3\" (22 8 -2 3)
See documentation for `version-separator' and `version-regexp-alist'."
+ (declare (side-effect-free t))
(unless (stringp ver)
(error "Version must be a string"))
;; Change .x.y to 0.x.y
string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
which is higher than \"1alpha\", which is higher than \"1snapshot\".
Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
+ (declare (side-effect-free t))
(version-list-< (version-to-list v1) (version-to-list v2)))
(defun version<= (v1 v2)
string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
which is higher than \"1alpha\", which is higher than \"1snapshot\".
Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
+ (declare (side-effect-free t))
(version-list-<= (version-to-list v1) (version-to-list v2)))
(defun version= (v1 v2)
string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
which is higher than \"1alpha\", which is higher than \"1snapshot\".
Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
+ (declare (side-effect-free t))
(version-list-= (version-to-list v1) (version-to-list v2)))
(defvar package--builtin-versions
"Trim STRING of leading string matching REGEXP.
REGEXP defaults to \"[ \\t\\n\\r]+\"."
+ (declare (important-return-value t))
(if (string-match (if regexp
(concat "\\`\\(?:" regexp "\\)")
"\\`[ \t\n\r]+")
"Trim STRING of leading and trailing strings matching TRIM-LEFT and TRIM-RIGHT.
TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
+ (declare (important-return-value t))
(string-trim-left (string-trim-right string trim-right) trim-left))
;; The initial anchoring is for better performance in searching matches.