unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: Leo Liu <sdl.web@gmail.com>
Cc: 18620@debbugs.gnu.org
Subject: bug#18620: 25.0.50; cfengine3-make-syntax-cache
Date: Mon, 06 Oct 2014 22:31:09 -0400	[thread overview]
Message-ID: <m21tqk7gr6.fsf@lifelogs.com> (raw)
In-Reply-To: <m3oattxxa1.fsf@gmail.com> (Leo Liu's message of "Fri, 03 Oct 2014 18:28:22 +0800")

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


  reply	other threads:[~2014-10-07  2:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 10:28 bug#18620: 25.0.50; cfengine3-make-syntax-cache Leo Liu
2014-10-07  2:31 ` Ted Zlatanov [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21tqk7gr6.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=18620@debbugs.gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).