summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-util.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/gnus-util.el')
-rw-r--r--lisp/gnus/gnus-util.el74
1 files changed, 12 insertions, 62 deletions
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 3c7c948c2b5..70ae81d95ea 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -154,7 +154,7 @@ is slower."
(and (string-match "(.+)" from)
(setq name (substring from (1+ (match-beginning 0))
(1- (match-end 0)))))
- (and (string-match "()" from)
+ (and (string-search "()" from)
(setq name address))
;; XOVER might not support folded From headers.
(and (string-match "(.*" from)
@@ -265,7 +265,7 @@ If END is non-nil, use the end of the span instead."
(defun gnus-newsgroup-directory-form (newsgroup)
"Make hierarchical directory name from NEWSGROUP name."
(let* ((newsgroup (gnus-newsgroup-savable-name newsgroup))
- (idx (string-match ":" newsgroup)))
+ (idx (string-search ":" newsgroup)))
(concat
(if idx (substring newsgroup 0 idx))
(if idx "/")
@@ -408,7 +408,7 @@ Cache the result as a text property stored in DATE."
(defun gnus-mode-string-quote (string)
"Quote all \"%\"'s in STRING."
- (replace-regexp-in-string "%" "%%" string))
+ (string-replace "%" "%%" string))
(defsubst gnus-make-hashtable (&optional size)
"Make a hash table of SIZE, testing on `equal'."
@@ -1068,6 +1068,11 @@ ARG is passed to the first function."
;;; Various
+(defmacro gnus--\,@ (exp)
+ "Splice EXP's value (a list of Lisp forms) into the code."
+ (declare (debug t))
+ `(progn ,@(eval exp t)))
+
(defvar gnus-group-buffer) ; Compiler directive
(defun gnus-alive-p ()
"Say whether Gnus is running or not."
@@ -1286,61 +1291,6 @@ forbidden in URL encoding."
(setq tmp (concat tmp str))
tmp))
-(defun gnus-base64-repad (str &optional reject-newlines line-length no-check)
- "Take a base 64-encoded string and return it padded correctly.
-Existing padding is ignored.
-
-If any combination of CR and LF characters are present and
-REJECT-NEWLINES is nil, remove them; otherwise raise an error.
-If LINE-LENGTH is set and the string (or any line in the string
-if REJECT-NEWLINES is nil) is longer than that number, raise an
-error. Common line length for input characters are 76 plus CRLF
-\(RFC 2045 MIME), 64 plus CRLF (RFC 1421 PEM), and 1000 including
-CRLF (RFC 5321 SMTP).
-
-If NOCHECK, don't check anything, but just repad."
- ;; RFC 4648 specifies that:
- ;; - three 8-bit inputs make up a 24-bit group
- ;; - the 24-bit group is broken up into four 6-bit values
- ;; - each 6-bit value is mapped to one character of the base 64 alphabet
- ;; - if the final 24-bit quantum is filled with only 8 bits the output
- ;; will be two base 64 characters followed by two "=" padding characters
- ;; - if the final 24-bit quantum is filled with only 16 bits the output
- ;; will be three base 64 character followed by one "=" padding character
- ;;
- ;; RFC 4648 section 3 considerations:
- ;; - if reject-newlines is nil (default), concatenate multi-line
- ;; input (3.1, 3.3)
- ;; - if line-length is set, error on input exceeding the limit (3.1)
- ;; - reject characters outside base encoding (3.3, also section 12)
- ;;
- ;; RFC 5322 section 2.2.3 consideration:
- ;; Because base 64-encoded strings can appear in long header fields, remove
- ;; folding whitespace while still observing the RFC 4648 decisions above.
- (when no-check
- (setq str (replace-regexp-in-string "[\n\r \t]+" "" str)));
- (let ((splitstr (split-string str "[ \t]*[\r\n]+[ \t]?" t)))
- (when (and reject-newlines (> (length splitstr) 1))
- (error "Invalid Base64 string"))
- (dolist (substr splitstr)
- (when (and line-length (> (length substr) line-length))
- (error "Base64 string exceeds line-length"))
- (when (string-match "[^A-Za-z0-9+/=]" substr)
- (error "Invalid Base64 string")))
- (let* ((str (string-join splitstr))
- (len (length str)))
- (when (string-match "=" str)
- (setq len (match-beginning 0)))
- (concat
- (substring str 0 len)
- (make-string (/
- (- 24
- (pcase (mod (* len 6) 24)
- (`0 24)
- (n n)))
- 6)
- ?=)))))
-
(defun gnus-make-predicate (spec)
"Transform SPEC into a function that can be called.
SPEC is a predicate specifier that contains stuff like `or', `and',
@@ -1607,8 +1557,8 @@ empty directories from OLD-PATH."
"Rescale IMAGE to SIZE if possible.
SIZE is in format (WIDTH . HEIGHT). Return a new image.
Sizes are in pixels."
- (if (not (display-graphic-p))
- image
+ (when (display-images-p)
+ (declare-function image-size "image.c" (spec &optional pixels frame))
(let ((new-width (car size))
(new-height (cdr size)))
(when (> (cdr (image-size image t)) new-height)
@@ -1616,8 +1566,8 @@ Sizes are in pixels."
:max-height new-height)))
(when (> (car (image-size image t)) new-width)
(setq image (create-image (plist-get (cdr image) :data) nil t
- :max-width new-width)))
- image)))
+ :max-width new-width)))))
+ image)
(defun gnus-recursive-directory-files (dir)
"Return all regular files below DIR.