Skip to content

org-ml-update-this-element fails with args out of range error if subtree is narrowed #56

Description

@eagerchatterjee

org-ml-update-this-element fails with args out of range error when acting on a narrowed subtree with a headline following it and a source block being the last element

Minimal Reproducible Example

  • execute the below org block with narrowed subtree to headline A
* Headline A
#+begin_src emacs-lisp :results output
(org-ml-update-this-element* (->> it (org-ml-set-property :language "sh")))
;; These lead to same error
;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work
;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work
#+end_src
* Headline B

Debug Trace

Debugger entered--Lisp error: (args-out-of-range #<buffer demo.org> 14 374)
  org-ml--diff-region(14 374 "#+begin_src sh :results raw\n(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n#+end_src\n")
  org-ml--replace-bounds(t 14 374 (src-block (:standard-properties [14 14 nil nil 374 0 nil planning element t nil nil nil nil #<buffer sammy.org> nil nil nil] :language "sh" :switches nil :parameters ":results raw" :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n")))
  org-ml--update(t #f(lambda (it) :dynbind (->> it (org-ml-set-property :language "sh"))) (src-block (:standard-properties [14 14 nil nil 374 0 nil planning element t nil nil nil nil #<buffer sammy.org> nil nil (section (:standard-properties [14 14 14 374 374 0 nil section element t nil 14 374 nil #<buffer sammy.org> nil nil (headline ...)]))] :language "emacs-lisp" :switches nil :parameters ":results raw" :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n")))
  org-ml~update(t #f(lambda (it) :dynbind (->> it (org-ml-set-property :language "sh"))) (src-block (:standard-properties [14 14 nil nil 374 0 nil planning element t nil nil nil nil #<buffer sammy.org> nil nil (section (:standard-properties [14 14 14 374 374 0 nil section element t nil 14 374 nil #<buffer sammy.org> nil nil (headline ...)]))] :language "emacs-lisp" :switches nil :parameters ":results raw" :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n")))
  org-ml~update-element-at(t 286 #f(lambda (it) :dynbind (->> it (org-ml-set-property :language "sh"))))
  org-ml~update-this-element(t #f(lambda (it) :dynbind (->> it (org-ml-set-property :language "sh"))))
  org-ml-update-this-element(#f(lambda (it) :dynbind (->> it (org-ml-set-property :language "sh"))))
  (org-ml-update-this-element* (->> it (org-ml-set-property :language "sh")))
  (progn (org-ml-update-this-element* (->> it (org-ml-set-property :language "sh"))))
  eval((progn (org-ml-update-this-element* (->> it (org-ml-set-property :language "sh")))) nil)
  org-babel-execute:emacs-lisp("(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "replace" "raw") (:result-type . value) (:results . "replace raw") (:exports . "code") (:session . "none") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no") (:lexical . "no")))
  #<subr org-babel-execute-src-block>(nil ("emacs-lisp" "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 14 "(ref:%s)") nil)
  apply(#<subr org-babel-execute-src-block> nil ("emacs-lisp" "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 14 "(ref:%s)") nil nil)
  (if (>= emacs-major-version 28) (apply orig-fun arg info params executor-type) (apply orig-fun arg info params))
  (if nix-shell-name (let* ((direnv (if nix-shell-name (progn (org-nix-shell--get-direnv nix-shell-name)))) (_ (if nix-shell-name (progn (org-nix-shell--apply-env direnv)))) (ret (if (>= emacs-major-version 28) (org-nix-shell--inheritenv-apply orig-fun arg info params executor-type) (org-nix-shell--inheritenv-apply orig-fun arg info params))) (_ (if nix-shell-name (progn (org-nix-shell--clear-env))))) ret) (if (>= emacs-major-version 28) (apply orig-fun arg info params executor-type) (apply orig-fun arg info params)))
  (let* ((nix-shell-name (org-nix-shell--process-params info params))) (if nix-shell-name (let* ((direnv (if nix-shell-name (progn (org-nix-shell--get-direnv nix-shell-name)))) (_ (if nix-shell-name (progn (org-nix-shell--apply-env direnv)))) (ret (if (>= emacs-major-version 28) (org-nix-shell--inheritenv-apply orig-fun arg info params executor-type) (org-nix-shell--inheritenv-apply orig-fun arg info params))) (_ (if nix-shell-name (progn (org-nix-shell--clear-env))))) ret) (if (>= emacs-major-version 28) (apply orig-fun arg info params executor-type) (apply orig-fun arg info params))))
  org-nix-shell--execute-src-block(#<subr org-babel-execute-src-block> nil ("emacs-lisp" "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 14 "(ref:%s)"))
  apply(org-nix-shell--execute-src-block #<subr org-babel-execute-src-block> (nil ("emacs-lisp" "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 14 "(ref:%s)")))
  org-babel-execute-src-block(nil ("emacs-lisp" "(org-ml-update-this-element* (->> it (org-ml-set-property :language \"sh\")))\n;; These lead to same error\n;(org-ml~update-this-element* nil (->> it (org-ml-set-property :language emacs-lisp))) also does not work\n;(org-ml~update-this-element* t (->> it (org-ml-set-property :language emacs-lisp))) also does not work" ((:colname-names) (:rowname-names) (:result-params "raw" "replace") (:result-type . value) (:results . "raw replace") (:exports . "code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 14 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  command-execute(org-ctrl-c-ctrl-c)

What Does Work

  • same command but subtree not narrowed
  • anything except post-blank line occuring in the subtree after the source block

Environment

  • GNU Emacs 30.2 (Spacemacs)
  • NixOS 25.05
  • evil mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions