emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block
@ 2022-04-24  3:18 Kaushal Modi
  2022-04-24  7:52 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Kaushal Modi @ 2022-04-24  3:18 UTC (permalink / raw)
  To: emacs-org list

[-- 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


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

* Re: [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block
  2022-04-24  3:18 [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block Kaushal Modi
@ 2022-04-24  7:52 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2022-04-24  7:52 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

Kaushal Modi <kaushal.modi@gmail.com> writes:

> 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?

Applied.

Thanks!

Best,
Ihor


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

end of thread, other threads:[~2022-04-24  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24  3:18 [PATCH] Fix inf-loop due to org-eldoc when point is in an org src block Kaushal Modi
2022-04-24  7:52 ` 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).