This replaces open coded versions of the common idiom
(not (eq (gethash key table 'missing) 'missing))
with
(hash-table-contains-p key table)
in files where we can rely on features in Emacs 31.
* lisp/emacs-lisp/map.el (map-contains-key):
* lisp/external-completion.el (external-completion-table):
* lisp/mh-e/mh-utils.el (mh-sub-folders)
(mh-remove-from-sub-folders-cache):
* lisp/net/ange-ftp.el (ange-ftp-hash-entry-exists-p):
* lisp/password-cache.el (password-in-cache-p, password-cache-add):
* lisp/pcmpl-x.el (pcmpl-x-tlmgr-action-options):
* lisp/xdg.el (xdg-mime-apps): Use 'hash-table-contains-p'.
(cherry picked from commit
f60fc1287d499e8c93857b1b96e8bd2467b22c8d)
(cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
"Return non-nil if MAP contains KEY, ignoring TESTFN."
- (let ((v '(nil)))
- (not (eq v (gethash key map v)))))
+ (hash-table-contains-p key map))
(cl-defgeneric map-some (pred map)
"Return the first non-nil value from applying PRED to elements of MAP.
completion-category-defaults)))
(let ((cache (make-hash-table :test #'equal)))
(cl-flet ((lookup-internal (string point)
- (let* ((key (cons string point))
- (probe (gethash key cache 'external--notfound)))
- (if (eq probe 'external--notfound)
- (puthash key (funcall lookup string point) cache)
- probe))))
+ (let ((key (cons string point)))
+ (if (hash-table-contains-p key cache)
+ (gethash key cache)
+ (puthash key (funcall lookup string point) cache)))))
(lambda (string pred action)
(pcase action
(`metadata
(defun ange-ftp-hash-entry-exists-p (key tbl)
"Return whether there is an association for KEY in table TBL."
- (and tbl (not (eq (gethash key tbl 'unknown) 'unknown))))
+ (and tbl (hash-table-contains-p key tbl)))
(defun ange-ftp-hash-table-keys (tbl)
"Return a sorted list of all the active keys in table TBL, as strings."
"Check if KEY is in the cache."
(and password-cache
key
- (not (eq (gethash key password-data 'password-cache-no-data)
- 'password-cache-no-data))))
+ (hash-table-contains-p key password-data)))
(defun password-read (prompt &optional key)
"Read password, for use with KEY, from user, or from cache if wanted.
"Add password to cache.
The password is removed by a timer after `password-cache-expiry' seconds."
(when (and password-cache-expiry
- (eq (gethash key password-data 'password-cache-no-data)
- 'password-cache-no-data))
+ (not (hash-table-contains-p key password-data)))
(run-at-time password-cache-expiry nil
#'password-cache-remove
key))
(defun pcmpl-x-tlmgr-action-options (action)
"Get the list of long options for ACTION."
- (if (eq (gethash action pcmpl-x-tlmgr-options-cache 'missing) 'missing)
+ (if (not (hash-table-contains-p action pcmpl-x-tlmgr-options-cache))
(with-temp-buffer
(when (zerop
(call-process pcmpl-x-tlmgr-program nil t nil action "-h"))
(setq xdg-mime-table nil)))
(when (null (assoc type xdg-mime-table))
(push (cons type (make-hash-table :test #'equal)) xdg-mime-table))
- (if (let ((def (make-symbol "def"))
- (table (cdr (assoc type xdg-mime-table))))
- (not (eq (setq files (gethash subtype table def)) def)))
+ (if (let ((table (cdr (assoc type xdg-mime-table))))
+ (hash-table-contains-p subtype table))
files
(and files (setq files nil))
(let ((dirs (mapcar (lambda (dir) (expand-file-name "applications" dir))