How to break out from maphash in Emacs Lisp?
问题 I need to exit early from maphash when I've found what I was looking for. (defun find-in-hash (str hash) (let ((match nil)) (maphash (lambda (key value) (if (string-prefix-p str key) (setq match key))) hash) match)) How would I do this in Emacs Lisp? 回答1: As explained in how to interrupt maphash you can place a maphash inside a block and exit the block via return-from , i.e. use the form (block stop-mapping (maphash ;; Function to call for all entries in ht. ;; A condition for when to stop