emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)]
@ 2023-02-26  4:13 Mark A. Hershberger
  2023-02-26 10:33 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Mark A. Hershberger @ 2023-02-26  4:13 UTC (permalink / raw)
  To: emacs-orgmode



Loading the following file with "emacs -Q", I'm un-able to type 'C-c
C-c' in the source block to execute it.

#+begin_src elisp
(defun count-lines (dir)
  "Number of lines in *.php files in a DIR."
  (let ((extdir (concat "../mediawiki/extensions/" dir)))
    (if (not (f-directory-p extdir))
        ""
        (let ((files (directory-files-recursively extdir "\\.php$"))
              (count 0))
          (dolist (file files)
            (setq count (+ count (-reduce '+ (mapcar 'file-lines (list file))))))
          count))))
#+end_src

When I do the following error appears:

⛔ Warning (org-element-cache): org-element--cache: Org parser error in tmp.org::4740. Resetting.
 The error was: (wrong-number-of-arguments (lambda (dir) "Number of lines in *.php files in a DIR." (let ((extdir (concat "../mediawiki/extensions/" dir))) (if (not (f-directory-p extdir)) "" (let ((files (directory-files-recursively extdir "\\.php$")) (count 0)) (dolist (file files) (setq count (+ count (-reduce '+ (mapcar 'file-lines (list file)))))) count)))) 2)
 Backtrace:
nil
 Please report this to Org mode mailing list (M-x org-submit-bug-report).



Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.16.0)
 of 2023-02-23
Package: Org mode version 9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)]
  2023-02-26  4:13 [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)] Mark A. Hershberger
@ 2023-02-26 10:33 ` Ihor Radchenko
  2023-02-26 10:38   ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-02-26 10:33 UTC (permalink / raw)
  To: Mark A. Hershberger; +Cc: emacs-orgmode

"Mark A. Hershberger" <mah@everybody.org> writes:

> Loading the following file with "emacs -Q", I'm un-able to type 'C-c
> C-c' in the source block to execute it.
>
> #+begin_src elisp
> (defun count-lines (dir)
> ...
> When I do the following error appears:
>
> ⛔ Warning (org-element-cache): org-element--cache: Org parser error in tmp.org::4740. Resetting.
>  The error was: (wrong-number-of-arguments (lambda (dir)

Canceled.

You are re-defining a built-in Elisp function `count-lines'. This
function is used by Org parser. That's why you are getting an error.

Re-defining built-in functions is generally dangerous. You need to know
what you are doing.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)]
  2023-02-26 10:33 ` Ihor Radchenko
@ 2023-02-26 10:38   ` Ihor Radchenko
  2023-02-26 14:54     ` Mark A. Hershberger
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-02-26 10:38 UTC (permalink / raw)
  To: Mark A. Hershberger; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Re-defining built-in functions is generally dangerous. You need to know
> what you are doing.

I recommend reading D.1 Emacs Lisp Coding Conventions section of Elisp
manual. In particular the paragraph about naming symbols and functions:

   • You should choose a short word to distinguish your program from
     other Lisp programs.  The names of all global symbols in your
     program, that is the names of variables, constants, and functions,
     should begin with that chosen prefix.  Separate the prefix from the
     rest of the name with a hyphen, ‘-’.  This practice helps avoid
     name conflicts, since all global variables in Emacs Lisp share the
     same name space, and all functions share another name space(1).
     Use two hyphens to separate prefix and name if the symbol is not
     meant to be used by other packages.

It is common among Emacs users to prefix personal functions with
"username/". Like `username/count-lines'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)]
  2023-02-26 10:38   ` Ihor Radchenko
@ 2023-02-26 14:54     ` Mark A. Hershberger
  2023-02-26 15:06       ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Mark A. Hershberger @ 2023-02-26 14:54 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Mark A. Hershberger, emacs-orgmode

Thanks for pointing out that I'm re-defining an internal function.

If I can reopen this issue, it would be good if the error message actually said that.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)]
  2023-02-26 14:54     ` Mark A. Hershberger
@ 2023-02-26 15:06       ` Ihor Radchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Ihor Radchenko @ 2023-02-26 15:06 UTC (permalink / raw)
  To: Mark A. Hershberger; +Cc: Mark A. Hershberger, emacs-orgmode

"Mark A. Hershberger" <mah@nichework.com> writes:

> If I can reopen this issue, it would be good if the error message actually said that.

Org has no idea which functions are built-in. Org has no idea which
functions are re-defined and just uses modified versions if the user
prefers re-defined version. Emacs gives this power to users. Use it with
caution. Or not use. Following naming conventions helps.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-26 15:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-26  4:13 [BUG] org parser error [9.6.1 (9.6.1-g351279 @ /home/mah/.emacs.d/straight/build/org/)] Mark A. Hershberger
2023-02-26 10:33 ` Ihor Radchenko
2023-02-26 10:38   ` Ihor Radchenko
2023-02-26 14:54     ` Mark A. Hershberger
2023-02-26 15:06       ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).