[llvm-bugs] [Bug 29073] New: Emacs clang-format functions don't work when narrowing is in effect

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 20 12:46:26 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29073

            Bug ID: 29073
           Summary: Emacs clang-format functions don't work when narrowing
                    is in effect
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: phst at google.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following invocation (to be modified depending on load path of
clang-format.el and location of the clang-format binary)

emacs -batch -q -l clang-format -eval '(progn (write-region "int a;\n" nil
"/tmp/clang.cpp") (find-file "/tmp/clang.cpp") (narrow-to-region 2 3)
(clang-format-buffer))'

results in an error

(clang-format failed with code 1: error: offset 1 is outside the file)

because clang-format-region passes only the accessible portion of the buffer to
the clang-format subprocess, not the entire buffer.  Possible (untested)
solution: In clang-format.el, replace (call-process-region (point-min)
(point-max) …) with (call-process-region nil nil …).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160820/70cf2ec0/attachment.html>


More information about the llvm-bugs mailing list