GNU bug report logs - #18620
25.0.50; cfengine3-make-syntax-cache

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Fri, 3 Oct 2014 10:30:04 UTC

Severity: normal

Found in version 25.0.50

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18620 in the body.
You can then email your comments to 18620 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to tzz <at> lifelogs.com, bug-gnu-emacs <at> gnu.org:
bug#18620; Package emacs. (Fri, 03 Oct 2014 10:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to tzz <at> lifelogs.com, bug-gnu-emacs <at> gnu.org. (Fri, 03 Oct 2014 10:30:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; cfengine3-make-syntax-cache
Date: Fri, 03 Oct 2014 18:28:22 +0800
There are multiple problems with cfengine3-make-syntax-cache:

1. call-process-shell-command changed in trunk; simply replace it with
   process-file.

2. it doesn't always return a `syntax' value

3. cf-promises doesn't have -s option in Centos 6.5 (cfengine 3.3)

HTH,
Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18620; Package emacs. (Tue, 07 Oct 2014 02:32:01 GMT) Full text and rfc822 format available.

Message #8 received at 18620 <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 18620 <at> debbugs.gnu.org
Subject: Re: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Mon, 06 Oct 2014 22:31:09 -0400
[Message part 1 (text/plain, inline)]
On Fri, 03 Oct 2014 18:28:22 +0800 Leo Liu <sdl.web <at> gmail.com> wrote: 

LL> There are multiple problems with cfengine3-make-syntax-cache:

LL> 1. call-process-shell-command changed in trunk; simply replace it with
LL>    process-file.

LL> 2. it doesn't always return a `syntax' value

Thanks for catching this, I had not noticed it sooner. Please see the
patch below; does it work for you? If so I will commit and close the
bug.

LL> 3. cf-promises doesn't have -s option in Centos 6.5 (cfengine 3.3)

I think that's all right, we will default to the fallback syntax. The
`-s' option was added after 3.3 but IMO the fallback syntax is good
enough for all 3.x work.

(Unfortunately the Red Hat ecosystem has no CFEngine package maintainers
so to get the latest you have to install from the official CFEngine
package repo as directed by their website.)

Thanks
Ted

[18620-cfengine-syntax.patch (text/x-patch, inline)]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2014-10-06 17:47:56 +0000
+++ lisp/ChangeLog	2014-10-07 02:18:14 +0000
@@ -1,3 +1,9 @@
+2014-10-07  Teodor Zlatanov  <tzz <at> lifelogs.com>
+
+	* progmodes/cfengine.el (cfengine3-make-syntax-cache): Use
+	`process-file' instead of `call-process-shell-command'.  Check if
+	the returned CFEngine syntax is reasonably valid (bug#18620).
+
 2014-10-06  Stefan Monnier  <monnier <at> iro.umontreal.ca>
 
 	* term/w32-win.el: Move all code from 32-common-fns.el here.

=== modified file 'lisp/progmodes/cfengine.el'
--- lisp/progmodes/cfengine.el	2014-01-30 07:42:57 +0000
+++ lisp/progmodes/cfengine.el	2014-10-07 02:15:16 +0000
@@ -1238,21 +1238,25 @@
         (or syntax
             (with-demoted-errors
                 (with-temp-buffer
-                  (call-process-shell-command cfengine-cf-promises
-                                              nil   ; no input
-                                              t     ; current buffer
-                                              nil   ; no redisplay
-                                              "-s" "json")
+                  (process-file cfengine-cf-promises
+                                nil   ; no input
+                                t     ; current buffer
+                                nil   ; no redisplay
+                                "-s" "json")
                   (goto-char (point-min))
                   (setq syntax (json-read))
-                  (setq cfengine-mode-syntax-cache
-                        (cons (cons cfengine-cf-promises syntax)
-                              cfengine-mode-syntax-cache))
-                  (setq cfengine-mode-syntax-functions-regex
-                        (regexp-opt (mapcar (lambda (def)
-                                              (format "%s" (car def)))
-                                            (cdr (assq 'functions syntax)))
-                                    'symbols))))))
+
+                  ;; if we got a valid syntax...
+                  (when (and (listp syntax)
+                             (assq 'functions syntax))
+                    (setq cfengine-mode-syntax-cache
+                          (cons (cons cfengine-cf-promises syntax)
+                                cfengine-mode-syntax-cache))
+                    (setq cfengine-mode-syntax-functions-regex
+                          (regexp-opt (mapcar (lambda (def)
+                                                (format "%s" (car def)))
+                                              (cdr (assq 'functions syntax)))
+                                      'symbols)))))))
     cfengine3-fallback-syntax))
 
 (defun cfengine3-documentation-function ()


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18620; Package emacs. (Tue, 07 Oct 2014 03:23:02 GMT) Full text and rfc822 format available.

Message #11 received at 18620 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: 18620 <at> debbugs.gnu.org
Subject: Re: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Tue, 07 Oct 2014 11:22:46 +0800
On 2014-10-06 22:31 -0400, Ted Zlatanov wrote:
> Thanks for catching this, I had not noticed it sooner. Please see the
> patch below; does it work for you? If so I will commit and close the
> bug.

cfengine3-make-syntax-cache may still return a regexp and it won't fall
back on cfengine3-fallback-syntax when `cf-promises -s json' fails; how
about something along these lines?

=== modified file 'lisp/progmodes/cfengine.el'
--- lisp/progmodes/cfengine.el	2014-01-30 07:42:57 +0000
+++ lisp/progmodes/cfengine.el	2014-10-07 03:10:44 +0000
@@ -1231,29 +1231,31 @@
   (setq cfengine-mode-syntax-cache nil))
 
 (defun cfengine3-make-syntax-cache ()
-  "Build the CFEngine 3 syntax cache.
+  "Build the CFEngine 3 syntax cache and return it.
 Calls `cfengine-cf-promises' with \"-s json\""
-  (let ((syntax (cddr (assoc cfengine-cf-promises cfengine-mode-syntax-cache))))
-    (if cfengine-cf-promises
-        (or syntax
-            (with-demoted-errors
-                (with-temp-buffer
-                  (call-process-shell-command cfengine-cf-promises
-                                              nil   ; no input
-                                              t     ; current buffer
-                                              nil   ; no redisplay
-                                              "-s" "json")
-                  (goto-char (point-min))
-                  (setq syntax (json-read))
-                  (setq cfengine-mode-syntax-cache
-                        (cons (cons cfengine-cf-promises syntax)
-                              cfengine-mode-syntax-cache))
-                  (setq cfengine-mode-syntax-functions-regex
-                        (regexp-opt (mapcar (lambda (def)
-                                              (format "%s" (car def)))
-                                            (cdr (assq 'functions syntax)))
-                                    'symbols))))))
-    cfengine3-fallback-syntax))
+  (or (cddr (assoc cfengine-cf-promises cfengine-mode-syntax-cache))
+      (when cfengine-cf-promises
+        (with-demoted-errors "cfengine3-make-syntax-cache: %S"
+          (with-temp-buffer
+            (process-file cfengine-cf-promises
+                          nil           ; no input
+                          t             ; current buffer
+                          nil           ; no redisplay
+                          "-s" "json")
+            (goto-char (point-min))
+            (let ((syntax (json-read)))
+              (when (and (listp syntax)
+                         (assq 'functions syntax))
+                (setq cfengine-mode-syntax-cache
+                      (cons (cons cfengine-cf-promises syntax)
+                            cfengine-mode-syntax-cache))
+                (setq cfengine-mode-syntax-functions-regex
+                      (regexp-opt (mapcar (lambda (def)
+                                            (format "%s" (car def)))
+                                          (cdr (assq 'functions syntax)))
+                                  'symbols))
+                syntax)))))
+      cfengine3-fallback-syntax))
 
 (defun cfengine3-documentation-function ()
   "Document CFengine 3 functions around point.
@@ -1265,7 +1267,6 @@
 
 (defun cfengine3-completion-function ()
   "Return completions for function name around or before point."
-  (cfengine3-make-syntax-cache)
   (let* ((bounds (save-excursion
                    (let ((p (point)))
                      (skip-syntax-backward "w_" (point-at-bol))

>
> LL> 3. cf-promises doesn't have -s option in Centos 6.5 (cfengine 3.3)
>
> I think that's all right, we will default to the fallback syntax. The
> `-s' option was added after 3.3 but IMO the fallback syntax is good
> enough for all 3.x work.
>
> (Unfortunately the Red Hat ecosystem has no CFEngine package maintainers
> so to get the latest you have to install from the official CFEngine
> package repo as directed by their website.)

Agreed. Sad to see this and the cf community seems not very active. BTW,
do you know if CF is still part of GNU? I only see version 2 on GNU¹.

>
> Thanks
> Ted

Thanks,
Leo

Footnotes: 
¹  http://www.gnu.org/software/cfengine/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18620; Package emacs. (Wed, 08 Oct 2014 13:52:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Wed, 08 Oct 2014 09:51:09 -0400
On Tue, 07 Oct 2014 11:22:46 +0800 Leo Liu <sdl.web <at> gmail.com> wrote: 

LL> On 2014-10-06 22:31 -0400, Ted Zlatanov wrote:
>> Thanks for catching this, I had not noticed it sooner. Please see the
>> patch below; does it work for you? If so I will commit and close the
>> bug.

LL> cfengine3-make-syntax-cache may still return a regexp and it won't fall
LL> back on cfengine3-fallback-syntax when `cf-promises -s json' fails; how
LL> about something along these lines?

I like your patch better :)

Can you commit or let me know and I will?  It will close this ticket, I
hope.

LL> 3. cf-promises doesn't have -s option in Centos 6.5 (cfengine 3.3)
>> 
>> I think that's all right, we will default to the fallback syntax. The
>> `-s' option was added after 3.3 but IMO the fallback syntax is good
>> enough for all 3.x work.
>> 
>> (Unfortunately the Red Hat ecosystem has no CFEngine package maintainers
>> so to get the latest you have to install from the official CFEngine
>> package repo as directed by their website.)

LL> Agreed. Sad to see this and the cf community seems not very active. BTW,
LL> do you know if CF is still part of GNU? I only see version 2 on GNU¹.

CFEngine 3 was a rewrite of version 2. It's still under the GPL but no
longer part of the GNU project AFAIK. IMO it's quite good (the latest
release is 3.6.2) and it's actively maintained by CFEngine Inc, but the
proprietary non-free extensions in their Enterprise version and the
corporate ownership of the codebase make it unlikely it can be part of
the GNU project in this incarnation.

Ted





Reply sent to Leo Liu <sdl.web <at> gmail.com>:
You have taken responsibility. (Wed, 08 Oct 2014 16:04:01 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Wed, 08 Oct 2014 16:04:02 GMT) Full text and rfc822 format available.

Message #19 received at 18620-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: 18620-done <at> debbugs.gnu.org
Subject: Re: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Thu, 09 Oct 2014 00:03:29 +0800
On 2014-10-08 09:51 -0400, Ted Zlatanov wrote:
> On Tue, 07 Oct 2014 11:22:46 +0800 Leo Liu <sdl.web <at> gmail.com> wrote: 
[snipped 9 lines]
>
> I like your patch better :)
>
> Can you commit or let me know and I will?  It will close this ticket, I
> hope.

OK, I am committing the patch (it's been 30 minutes, it hurts when it is
this slow). I have discovered a few other issues and fixed them along
the way. If you have time could you test it to make sure I don't break
something else.

[snipped 12 lines]
>
> CFEngine 3 was a rewrite of version 2. It's still under the GPL but no
> longer part of the GNU project AFAIK. IMO it's quite good (the latest
> release is 3.6.2) and it's actively maintained by CFEngine Inc, but the
> proprietary non-free extensions in their Enterprise version and the
> corporate ownership of the codebase make it unlikely it can be part of
> the GNU project in this incarnation.
>
> Ted

I'll take your word for it ;) Thanks for the info.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18620; Package emacs. (Thu, 09 Oct 2014 13:21:02 GMT) Full text and rfc822 format available.

Message #22 received at 18620-done <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: 18620-done <at> debbugs.gnu.org
Cc: sdl.web <at> gmail.com
Subject: Re: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Thu, 09 Oct 2014 09:20:42 -0400
On Thu, 09 Oct 2014 00:03:29 +0800 Leo Liu <sdl.web <at> gmail.com> wrote: 

LL> OK, I am committing the patch (it's been 30 minutes, it hurts when it is
LL> this slow). I have discovered a few other issues and fixed them along
LL> the way. If you have time could you test it to make sure I don't break
LL> something else.

It's good. I'll keep testing it; marking the bug done.

Thanks for the help!
Ted




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 07 Nov 2014 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.