unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18620: 25.0.50; cfengine3-make-syntax-cache
@ 2014-10-03 10:28 Leo Liu
  2014-10-07  2:31 ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2014-10-03 10:28 UTC (permalink / raw)
  To: 18620; +Cc: tzz


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





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

* bug#18620: 25.0.50; cfengine3-make-syntax-cache
  2014-10-03 10:28 bug#18620: 25.0.50; cfengine3-make-syntax-cache Leo Liu
@ 2014-10-07  2:31 ` Ted Zlatanov
  2014-10-07  3:22   ` Leo Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Ted Zlatanov @ 2014-10-07  2:31 UTC (permalink / raw)
  To: Leo Liu; +Cc: 18620

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

On Fri, 03 Oct 2014 18:28:22 +0800 Leo Liu <sdl.web@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 18620-cfengine-syntax.patch --]
[-- Type: text/x-patch, Size: 2711 bytes --]

=== 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@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@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 ()


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

* bug#18620: 25.0.50; cfengine3-make-syntax-cache
  2014-10-07  2:31 ` Ted Zlatanov
@ 2014-10-07  3:22   ` Leo Liu
  2014-10-08 13:51     ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2014-10-07  3:22 UTC (permalink / raw)
  To: 18620

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/





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

* bug#18620: 25.0.50; cfengine3-make-syntax-cache
  2014-10-07  3:22   ` Leo Liu
@ 2014-10-08 13:51     ` Ted Zlatanov
  2014-10-08 16:03       ` Leo Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Ted Zlatanov @ 2014-10-08 13:51 UTC (permalink / raw)
  To: 18620

On Tue, 07 Oct 2014 11:22:46 +0800 Leo Liu <sdl.web@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






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

* bug#18620: 25.0.50; cfengine3-make-syntax-cache
  2014-10-08 13:51     ` Ted Zlatanov
@ 2014-10-08 16:03       ` Leo Liu
  2014-10-09 13:20         ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Liu @ 2014-10-08 16:03 UTC (permalink / raw)
  To: 18620-done

On 2014-10-08 09:51 -0400, Ted Zlatanov wrote:
> On Tue, 07 Oct 2014 11:22:46 +0800 Leo Liu <sdl.web@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





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

* bug#18620: 25.0.50; cfengine3-make-syntax-cache
  2014-10-08 16:03       ` Leo Liu
@ 2014-10-09 13:20         ` Ted Zlatanov
  0 siblings, 0 replies; 6+ messages in thread
From: Ted Zlatanov @ 2014-10-09 13:20 UTC (permalink / raw)
  To: 18620-done; +Cc: sdl.web

On Thu, 09 Oct 2014 00:03:29 +0800 Leo Liu <sdl.web@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





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

end of thread, other threads:[~2014-10-09 13:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-03 10:28 bug#18620: 25.0.50; cfengine3-make-syntax-cache Leo Liu
2014-10-07  2:31 ` Ted Zlatanov
2014-10-07  3:22   ` Leo Liu
2014-10-08 13:51     ` Ted Zlatanov
2014-10-08 16:03       ` Leo Liu
2014-10-09 13:20         ` Ted Zlatanov

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

	https://git.savannah.gnu.org/cgit/emacs.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).