@@ -6639,7 +6639,9 @@ Otherwise return cons of current string, symbol or list bounds."
66396639 (org-back-to-heading t)
66406640 (point))
66416641 (progn
6642- (org-end-of-subtree t t)
6642+ (outline-mark-subtree)
6643+ (exchange-point-and-mark)
6644+ (deactivate-mark)
66436645 (when (and (org-at-heading-p)
66446646 (not (eobp)))
66456647 (backward-char 1))
@@ -7640,42 +7642,48 @@ Defaults to `error'."
76407642(defun lispy--function-parse (str)
76417643 "Extract the function body and args from it's expression STR."
76427644 (let ((body (lispy--read str))
7643- args)
7644- (cond ((eq (car body) 'lambda)
7645- (setq body (cons 'defun body)))
7646- ((eq (car body) 'closure)
7647- (setq body `(defun noname ,@(cddr body))))
7648- ((eq (car body) 'defsubst)
7649- (setq body (cons 'defun (cdr body)))))
7650- (cond ((memq (car body) '(defun defmacro))
7651- (setq body (lispy--whitespace-trim (cdr body))))
7652- ((eq (car body) 'defalias)
7653- (let ((name (cadr (cadr (read str)))))
7654- (setq body
7655- (cons name (cdr (symbol-function name))))))
7656- (t
7657- (error "Expected defun, defmacro, or defalias got %s" (car body))))
7658- (if (symbolp (car body))
7659- (setq body (lispy--whitespace-trim (cdr body)))
7660- (error "Expected function name, got %s" (car body)))
7661- (if (listp (car body))
7662- (progn
7663- (setq args (car body))
7645+ args)
7646+ (if (not (consp body))
7647+ (progn (setq args (aref body 0))
7648+ (setq body (aref body 1)))
7649+ ;; In Emacs 30, `read' returns a dedicated type, instead of
7650+ ;; simple list, for lambdas, defuns, closures, etc. And code
7651+ ;; below is only valid for `defmacro'. Keep it for Emacs < 30.
7652+ (cond ((eq (car body) 'lambda)
7653+ (setq body (cons 'defun body)))
7654+ ((eq (car body) 'closure)
7655+ (setq body `(defun noname ,@(cddr body))))
7656+ ((eq (car body) 'defsubst)
7657+ (setq body (cons 'defun (cdr body)))))
7658+ (cond ((memq (car body) '(defun defmacro))
7659+ (setq body (lispy--whitespace-trim (cdr body))))
7660+ ((eq (car body) 'defalias)
7661+ (let ((name (cadr (cadr (read str)))))
7662+ (setq body
7663+ (cons name (cdr (symbol-function name))))))
7664+ (t
7665+ (error "Expected defun, defmacro, or defalias got %s" (car body))))
7666+ (if (symbolp (car body))
7667+ (setq body (lispy--whitespace-trim (cdr body)))
7668+ (error "Expected function name, got %s" (car body)))
7669+ (if (listp (car body))
7670+ (progn
7671+ (setq args (car body))
7672+ (setq body (lispy--whitespace-trim (cdr body))))
7673+ (error "Expected function arguments, got %s" (car body)))
7674+ ;; skip docstring
7675+ (if (and (listp (car body))
7676+ (eq (caar body) 'ly-raw)
7677+ (eq (cadar body) 'string))
7678+ (setq body (lispy--whitespace-trim (cdr body))))
7679+ ;; skip declare
7680+ (if (and (listp (car body))
7681+ (eq (caar body) 'declare))
76647682 (setq body (lispy--whitespace-trim (cdr body))))
7665- (error "Expected function arguments, got %s" (car body)))
7666- ;; skip docstring
7667- (if (and (listp (car body))
7668- (eq (caar body) 'ly-raw)
7669- (eq (cadar body) 'string))
7670- (setq body (lispy--whitespace-trim (cdr body))))
7671- ;; skip declare
7672- (if (and (listp (car body))
7673- (eq (caar body) 'declare))
7674- (setq body (lispy--whitespace-trim (cdr body))))
7675- ;; skip interactive
7676- (if (and (listp (car body))
7677- (eq (caar body) 'interactive))
7678- (setq body (lispy--whitespace-trim (cdr body))))
7683+ ;; skip interactive
7684+ (if (and (listp (car body))
7685+ (eq (caar body) 'interactive))
7686+ (setq body (lispy--whitespace-trim (cdr body)))))
76797687 (list args body)))
76807688
76817689(defun lispy--flatten-function (fstr e-args)
0 commit comments