emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block
Date: Sat, 23 Apr 2022 23:18:25 -0400	[thread overview]
Message-ID: <CAFyQvY317f2VVgU67Mt9maO=CPfeQkHaAsMHT8Mb8LQgGHA=-w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hello all,

The patches attached in this email fix the issue reported in
https://lists.gnu.org/r/emacs-orgmode/2022-04/msg00373.html. They are
based off the master branch of https://git.sr.ht/~bzg/org-contrib.

patch 1: Minor cleanup in the function that I am touching for the fix
in patch 2: re-indent, untabify
patch 2: Fix for the inf-loop

Can someone please review and apply these patches to the org-contrib repo?
[I am unable to commit using ssh/git: protocol (only https is allowed)
based on the network restrictions at work.]

Thanks!

--
Kaushal Modi

[-- Attachment #2: 0001-lisp-org-eldoc.el-Whitespace-change.patch --]
[-- Type: application/octet-stream, Size: 4027 bytes --]

From 008185b9dfe50e4d8130a6418272ed693ccadb32 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Sat, 23 Apr 2022 22:46:40 -0400
Subject: [PATCH 1/2] lisp/org-eldoc.el: Whitespace change

(org-eldoc-documentation-function): Re-indent, clean up tabs
---
 lisp/org-eldoc.el | 72 +++++++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 34 deletions(-)

diff --git a/lisp/org-eldoc.el b/lisp/org-eldoc.el
index eb949f9..4febac1 100644
--- a/lisp/org-eldoc.el
+++ b/lisp/org-eldoc.el
@@ -141,40 +141,44 @@
    (org-eldoc-get-breadcrumb)
    (org-eldoc-get-src-header)
    (let ((lang (org-eldoc-get-src-lang)))
-     (cond ((or
-             (string= lang "emacs-lisp")
-             (string= lang "elisp"))
-	    (cond ((and (boundp 'eldoc-documentation-functions) ; Emacs>=28
-			(fboundp 'elisp-eldoc-var-docstring)
-			(fboundp 'elisp-eldoc-funcall))
-		   (let ((eldoc-documentation-functions
-			  '(elisp-eldoc-var-docstring elisp-eldoc-funcall)))
-		     (eldoc-print-current-symbol-info)))
-		  ((fboundp 'elisp-eldoc-documentation-function)
-		   (elisp-eldoc-documentation-function))
-		  (t  			; Emacs<25
-		   (let (eldoc-documentation-function)
-		     (eldoc-print-current-symbol-info)))))
-           ((or
-             (string= lang "c") ;; https://github.com/nflath/c-eldoc
-             (string= lang "C")) (when (require 'c-eldoc nil t)
-                                   (c-eldoc-print-current-symbol-info)))
-           ;; https://github.com/zenozeng/css-eldoc
-           ((string= lang "css") (when (require 'css-eldoc nil t)
-                                   (css-eldoc-function)))
-           ;; https://github.com/zenozeng/php-eldoc
-           ((string= lang "php") (when (require 'php-eldoc nil t)
-                                   (php-eldoc-function)))
-           ((or
-             (string= lang "go")
-             (string= lang "golang")) (when (require 'go-eldoc nil t)
-                                        (go-eldoc--documentation-function)))
-           (t (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
-		    (callback (car args)))
-                (when (functionp doc-fun)
-		  (if (functionp callback)
-		      (funcall doc-fun callback)
-		    (funcall doc-fun)))))))))
+     (cond
+      ((or
+        (string= lang "emacs-lisp")
+        (string= lang "elisp"))
+       (cond ((and (boundp 'eldoc-documentation-functions) ; Emacs>=28
+                   (fboundp 'elisp-eldoc-var-docstring)
+                   (fboundp 'elisp-eldoc-funcall))
+              (let ((eldoc-documentation-functions
+                     '(elisp-eldoc-var-docstring elisp-eldoc-funcall)))
+                (eldoc-print-current-symbol-info)))
+             ((fboundp 'elisp-eldoc-documentation-function)
+              (elisp-eldoc-documentation-function))
+             (t            ; Emacs<25
+              (let (eldoc-documentation-function)
+                (eldoc-print-current-symbol-info)))))
+      ((or
+        (string= lang "c") ;; https://github.com/nflath/c-eldoc
+        (string= lang "C"))
+       (when (require 'c-eldoc nil t)
+         (c-eldoc-print-current-symbol-info)))
+      ;; https://github.com/zenozeng/css-eldoc
+      ((string= lang "css") (when (require 'css-eldoc nil t)
+                              (css-eldoc-function)))
+      ;; https://github.com/zenozeng/php-eldoc
+      ((string= lang "php") (when (require 'php-eldoc nil t)
+                              (php-eldoc-function)))
+      ((or
+        (string= lang "go")
+        (string= lang "golang"))
+       (when (require 'go-eldoc nil t)
+         (go-eldoc--documentation-function)))
+      (t
+       (let ((doc-fun (org-eldoc-get-mode-local-documentation-function lang))
+             (callback (car args)))
+         (when (functionp doc-fun)
+           (if (functionp callback)
+               (funcall doc-fun callback)
+             (funcall doc-fun)))))))))
 
 ;;;###autoload
 (defun org-eldoc-load ()
-- 
2.34.0


[-- Attachment #3: 0002-lisp-org-eldoc.el-Fix-inf-loop-when-point-in-org-src.patch --]
[-- Type: application/octet-stream, Size: 981 bytes --]

From 216f33974928f2c4ddf31eef8dd8c2d2062f0422 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Sat, 23 Apr 2022 22:50:07 -0400
Subject: [PATCH 2/2] lisp/org-eldoc.el: Fix inf-loop when point in org src
 blocks

(org-eldoc-documentation-function): Return nil when src block lang is
"org".  Without this, the `org-eldoc-documentation-function' is
repeated called and causes an inf-loop.

Fixes the issue reported in
<https://lists.gnu.org/r/emacs-orgmode/2022-04/msg00373.html>.
---
 lisp/org-eldoc.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/org-eldoc.el b/lisp/org-eldoc.el
index 4febac1..3435745 100644
--- a/lisp/org-eldoc.el
+++ b/lisp/org-eldoc.el
@@ -142,6 +142,8 @@
    (org-eldoc-get-src-header)
    (let ((lang (org-eldoc-get-src-lang)))
      (cond
+      ((string= lang "org")       ;Prevent inf-loop for Org src blocks
+       nil)
       ((or
         (string= lang "emacs-lisp")
         (string= lang "elisp"))
-- 
2.34.0


             reply	other threads:[~2022-04-24  3:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24  3:18 Kaushal Modi [this message]
2022-04-24  7:52 ` [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFyQvY317f2VVgU67Mt9maO=CPfeQkHaAsMHT8Mb8LQgGHA=-w@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).