bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#18620: 25.0.50; cfengine3-make-syntax-cache


From: Ted Zlatanov
Subject: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Mon, 06 Oct 2014 22:31:09 -0400
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (darwin)

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

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


reply via email to

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