-;; notmuch-parser.el --- streaming S-expression parser
+;;; notmuch-parser.el --- streaming S-expression parser
;;
;; Copyright © Austin Clements
;;
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
-;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
+;; along with Notmuch. If not, see <https://www.gnu.org/licenses/>.
;;
;; Authors: Austin Clements <aclements@csail.mit.edu>
-(require 'cl)
+;;; Code:
+
+(eval-when-compile (require 'cl-lib))
(defun notmuch-sexp-create-parser ()
"Return a new streaming S-expression parser.
;; error to be consistent with all other code paths.
(read (current-buffer))
;; Go up a level and return an end token
- (decf (notmuch-sexp--depth sp))
+ (cl-decf (notmuch-sexp--depth sp))
(forward-char)
'end))
((= (char-after) ?\()
(notmuch-sexp--partial-state sp)))
;; A complete value is available if we've
;; reached depth 0.
- (depth (first new-state)))
- (assert (>= depth 0))
+ (depth (car new-state)))
+ (cl-assert (>= depth 0))
(if (= depth 0)
;; Reset partial parse state
(setf (notmuch-sexp--partial-state sp) nil
(cond ((eobp) 'retry)
((= (char-after) ?\()
(forward-char)
- (incf (notmuch-sexp--depth sp))
+ (cl-incf (notmuch-sexp--depth sp))
t)
(t
;; Skip over the bad character like `read' does
(set (make-local-variable 'notmuch-sexp--state) 'begin))
(let (done)
(while (not done)
- (case notmuch-sexp--state
+ (cl-case notmuch-sexp--state
(begin
;; Enter the list
(if (eq (notmuch-sexp-begin-list notmuch-sexp--parser) 'retry)
(result
;; Parse a result
(let ((result (notmuch-sexp-read notmuch-sexp--parser)))
- (case result
+ (cl-case result
(retry (setq done t))
(end (setq notmuch-sexp--state 'end))
(t (with-current-buffer result-buffer
(provide 'notmuch-parser)
-;; Local Variables:
-;; byte-compile-warnings: (not cl-functions)
-;; End:
+;;; notmuch-parser.el ends here