emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimise 'while' bodies for effect


From: Basil L. Contovounesios
Subject: Re: Optimise 'while' bodies for effect
Date: Tue, 14 Apr 2020 16:05:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Mattias EngdegÄrd <address@hidden> writes:

> I leave the other warnings to Gnus and Org specialists.

I'm not an Org specialist, but I think the only warning currently
emitted during 'make bootstrap' can be easily avoided by doing something
like the following:

>From a9fbf6612c1303beef0b313acd9dd7febc432084 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <address@hidden>
Date: Tue, 14 Apr 2020 15:26:04 +0100
Subject: [PATCH] Fix effect-free warning in ob-screen.el while loop

The warning was introduced and detected by an optimizer addition
proposed in the following thread:
https://lists.gnu.org/archive/html/emacs-devel/2019-12/msg00711.html

* lisp/org/ob-screen.el (org-babel-screen-test): Avoid 'value
returned from (format "...") is unused' warning by doing something
more useful than busy string manipulation while waiting for an
asynchronous subprocess to make the temporary file readable.
---
 lisp/org/ob-screen.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org/ob-screen.el b/lisp/org/ob-screen.el
index ad00ee070d..837c18f840 100644
--- a/lisp/org/ob-screen.el
+++ b/lisp/org/ob-screen.el
@@ -126,7 +126,7 @@ org-babel-screen-test
     ;; XXX: need to find a better way to do the following
     (while (not (file-readable-p tmpfile))
       ;; do something, otherwise this will be optimized away
-      (format "org-babel-screen: File not readable yet."))
+      (sit-for 0.1))
     (setq tmp-string (with-temp-buffer
                        (insert-file-contents-literally tmpfile)
                        (buffer-substring (point-min) (point-max))))
-- 
2.25.1

The whole function/library could use some love, but since
org-babel-screen-test is intended as a manual test command,
I think the proposed tweak is good enough.  WDYT?

Thanks,

-- 
Basil

reply via email to

[Prev in Thread] Current Thread [Next in Thread]