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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to