emacs-devel
[Top][All Lists]
Advanced

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

Re: New Flymake rewrite in emacs-26


From: João Távora
Subject: Re: New Flymake rewrite in emacs-26
Date: Wed, 11 Oct 2017 13:25:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux)

Noam Postavsky <address@hidden> writes:

>>> Another possibility is to put an echoing command in front and exploit
>>> the shell's parsing directly, e.g.,
>>>
>>>   printf '%s\0' gcc -c -Demacs -I. -I. -I../lib -I../ ...

I tried with Emacs itself, as you suggested. It works, and may be a
start, but:

* is very slow (only needs to run once though)
* no idea if it works for windows (it should if shell-command DTRT)
* generally looks brittle. Among other things it takes advantage of an
  undocumented "--" command-line arg.

    (defun flymake--gcc-heroic-unescape (string)
      (with-temp-buffer
        (let ((error-buffer (current-buffer)))
          (with-temp-buffer
            (cond
             ((zerop
               (shell-command
                (format
                 "%s -Q --batch --eval \"%s\" -- %s"
                 (expand-file-name invocation-name
                                   invocation-directory)
                 "(mapc 'print (nthcdr 4 command-line-args))"
                 string)
                (current-buffer)
                error-buffer))
              (goto-char (point-min))
              (cl-loop with eof = (make-symbol "eof")
                       for form =
                       (condition-case err
                           (read (current-buffer))
                         (error eof))
                       while (not (eq form eof))
                       collect form))
             (t
              (with-current-buffer error-buffer
                (error (buffer-string)))))))))
     
    (flymake--gcc-heroic-unescape "bla\\ bla") ; ("bla bla")
     
    (flymake-gcc-heroic-unescape "bla bla") ;("bla" "bla")






reply via email to

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