File: open_quickfix_in_editor.py

package info (click to toggle)
blender-doc 4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 253,604 kB
  • sloc: python: 13,030; javascript: 322; makefile: 113; sh: 107
file content (53 lines) | stat: -rwxr-xr-x 1,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3

"""
Utility to open an warning/error reports in an editor, a list of locations:

/path/file.ext:line:col:
"""

import sys
import shutil
import subprocess


def run(cmd):
    proc = subprocess.Popen(cmd, shell=False)
    proc.wait()
    return proc.returncode


logfile = sys.argv[-1]

if shutil.which("emacsclient"):
    sys.exit(run((
        "emacsclient",
        "--eval",
        # Calling: (compile-goto-error) should work but doesn't open window when called from here.

        "(progn "
        "  (find-file " f"\"{logfile}\")"
        "  (compilation-mode)"
        # To to the last non-blank line.
        "  (goto-char (point-max))"
        "  (skip-chars-backward \"\n[:space:]\")"
        "  (move-beginning-of-line nil)"
        ")",
        "--no-wait",
        "--alternate-editor=emacs --eval",
    )))

elif shutil.which("gvim"):
    sys.exit(run((
        "gvim",
        "--nofork",
        "-c",
        "cfile rst_check_syntax.log",
        "-c"
        "cope",
        "-c",
        "clast",
    )))
else:
    print("Error, no editor found (emacsclient, gvim)")
    sys.exit(1)