Added a command-line option to define the editor command.
This commit is contained in:
parent
cee53ed9d6
commit
431d4cf976
2 changed files with 32 additions and 22 deletions
|
|
@ -24,6 +24,8 @@
|
||||||
│ -n --no-sandbox Don't prevent changes to the filesystem. │
|
│ -n --no-sandbox Don't prevent changes to the filesystem. │
|
||||||
│ -w COUNT --workers=COUNT The number of processes working in parallel. │
|
│ -w COUNT --workers=COUNT The number of processes working in parallel. │
|
||||||
│ By default it is twice the number of cpus. │
|
│ By default it is twice the number of cpus. │
|
||||||
|
│ -e "COMMAND" --editor="COMMAND" The command used to start the editor, in │
|
||||||
|
│ the [0m[38;2;0;255;0m[48;2;0;0;0me[0m[38;2;255;255;255m[48;2;0;0;0mdit command. It may contain options. │
|
||||||
│ │
|
│ │
|
||||||
│Keys: │
|
│Keys: │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mh[0m[38;2;255;255;255m[48;2;0;0;0m - Show the help screen. (toggle) │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mh[0m[38;2;255;255;255m[48;2;0;0;0m - Show the help screen. (toggle) │
|
||||||
|
|
@ -33,7 +35,7 @@
|
||||||
│ Scroll the result pane. │
|
│ Scroll the result pane. │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mt[0m[38;2;255;255;255m[48;2;0;0;0m - Turn the result pane to portrait or landscape orientation. (toggle) │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mt[0m[38;2;255;255;255m[48;2;0;0;0m - Turn the result pane to portrait or landscape orientation. (toggle) │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0ml[0m[38;2;255;255;255m[48;2;0;0;0m - Show the activity log. (toggle) │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0ml[0m[38;2;255;255;255m[48;2;0;0;0m - Show the activity log. (toggle) │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0me[0m[38;2;255;255;255m[48;2;0;0;0m - Edit the current file in emacs. (Uses emacsclient) │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0me[0m[38;2;255;255;255m[48;2;0;0;0m - Edit the current file with a seperate editor. (-e or $EDITOR or $VISUAL) │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mn[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue. │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mn[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue. │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mN[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue of the current tool. │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mN[0m[38;2;255;255;255m[48;2;0;0;0m - Move to the next issue of the current tool. │
|
||||||
│ [0m[38;2;0;255;0m[48;2;0;0;0mp[0m[38;2;255;255;255m[48;2;0;0;0m - Pause workers. (toggle) │
|
│ [0m[38;2;0;255;0m[48;2;0;0;0mp[0m[38;2;255;255;255m[48;2;0;0;0m - Pause workers. (toggle) │
|
||||||
|
|
@ -55,6 +57,4 @@
|
||||||
│ │
|
│ │
|
||||||
│ │
|
│ │
|
||||||
│ │
|
│ │
|
||||||
│ │
|
|
||||||
│ │
|
|
||||||
└──────────────────────────────────────────────────────────────────────────────────────────────────┘[0m
|
└──────────────────────────────────────────────────────────────────────────────────────────────────┘[0m
|
||||||
24
vigil
24
vigil
|
|
@ -30,6 +30,8 @@ Options:
|
||||||
-n --no-sandbox Don't prevent changes to the filesystem.
|
-n --no-sandbox Don't prevent changes to the filesystem.
|
||||||
-w COUNT --workers=COUNT The number of processes working in parallel.
|
-w COUNT --workers=COUNT The number of processes working in parallel.
|
||||||
By default it is twice the number of cpus.
|
By default it is twice the number of cpus.
|
||||||
|
-e "COMMAND" --editor="COMMAND" The command used to start the editor, in
|
||||||
|
the *edit command. It may contain options.
|
||||||
|
|
||||||
Keys:
|
Keys:
|
||||||
*h - Show the help screen. (toggle)
|
*h - Show the help screen. (toggle)
|
||||||
|
|
@ -39,7 +41,7 @@ Keys:
|
||||||
Scroll the result pane.
|
Scroll the result pane.
|
||||||
*t - Turn the result pane to portrait or landscape orientation. (toggle)
|
*t - Turn the result pane to portrait or landscape orientation. (toggle)
|
||||||
*l - Show the activity log. (toggle)
|
*l - Show the activity log. (toggle)
|
||||||
*e - Edit the current file in emacs. (Uses emacsclient)
|
*e - Edit the current file with a seperate editor. (-e or $EDITOR or $VISUAL)
|
||||||
*n - Move to the next issue.
|
*n - Move to the next issue.
|
||||||
*N - Move to the next issue of the current tool.
|
*N - Move to the next issue of the current tool.
|
||||||
*p - Pause workers. (toggle)
|
*p - Pause workers. (toggle)
|
||||||
|
|
@ -755,11 +757,16 @@ class Screen:
|
||||||
self._summary.move_to_next_issue_of_tool()
|
self._summary.move_to_next_issue_of_tool()
|
||||||
|
|
||||||
def edit_file(self):
|
def edit_file(self):
|
||||||
|
if self.editor_command is None:
|
||||||
|
self._log.log_message("An editor has not been defined. "
|
||||||
|
"See option -e.")
|
||||||
|
else:
|
||||||
path = self._summary.get_selection().path
|
path = self._summary.get_selection().path
|
||||||
path_colored = tools._path_colored(path)
|
path_colored = tools._path_colored(path)
|
||||||
self._log.log_message([in_green("Editing "), path_colored,
|
self._log.log_message([in_green("Editing "), path_colored,
|
||||||
in_green(" in emacs...")])
|
in_green(' with command: "%s"...'
|
||||||
subprocess.Popen(["emacsclient", path],
|
% self.editor_command)])
|
||||||
|
subprocess.Popen("%s %s" % (self.editor_command, path), shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
def toggle_status_style(self):
|
def toggle_status_style(self):
|
||||||
|
|
@ -988,7 +995,7 @@ def update_screen(main_widget, appearance_changed_event):
|
||||||
|
|
||||||
|
|
||||||
def main(root_path, worker_count=multiprocessing.cpu_count()*2,
|
def main(root_path, worker_count=multiprocessing.cpu_count()*2,
|
||||||
is_sandboxed=True, is_being_tested=False):
|
is_sandboxed=True, editor_command=None, is_being_tested=False):
|
||||||
global _UPDATE_THREAD_STOPPED
|
global _UPDATE_THREAD_STOPPED
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
jobs_added_event = threading.Event()
|
jobs_added_event = threading.Event()
|
||||||
|
|
@ -1011,6 +1018,7 @@ def main(root_path, worker_count=multiprocessing.cpu_count()*2,
|
||||||
log = screen._log
|
log = screen._log
|
||||||
log._appearance_changed_event = appearance_changed_event
|
log._appearance_changed_event = appearance_changed_event
|
||||||
summary.sync_with_filesystem()
|
summary.sync_with_filesystem()
|
||||||
|
screen.editor_command = editor_command
|
||||||
log.delete_log_file()
|
log.delete_log_file()
|
||||||
log.log_message("Program started.")
|
log.log_message("Program started.")
|
||||||
jobs_added_event.set()
|
jobs_added_event.set()
|
||||||
|
|
@ -1133,15 +1141,17 @@ def process_arguments():
|
||||||
print("File is not a directory:", root_path)
|
print("File is not a directory:", root_path)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
is_sandboxed = not arguments["--no-sandbox"]
|
is_sandboxed = not arguments["--no-sandbox"]
|
||||||
return root_path, worker_count, is_sandboxed
|
editor_command = (arguments["--editor"] or os.environ.get("EDITOR", None)
|
||||||
|
or os.environ.get("VISUAL", None))
|
||||||
|
return root_path, worker_count, is_sandboxed, editor_command
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
root_path, worker_count, is_sandboxed = process_arguments()
|
root_path, worker_count, is_sandboxed, editor_command = process_arguments()
|
||||||
if is_sandboxed:
|
if is_sandboxed:
|
||||||
subprocess.call(["sudo", "-p", "Vigil needs sudo to create the filesy"
|
subprocess.call(["sudo", "-p", "Vigil needs sudo to create the filesy"
|
||||||
"stem sandbox... [sudo] password for %u: ", "true"])
|
"stem sandbox... [sudo] password for %u: ", "true"])
|
||||||
with terminal.console_title("vigil: " + os.path.basename(root_path)):
|
with terminal.console_title("vigil: " + os.path.basename(root_path)):
|
||||||
manage_cache(root_path)
|
manage_cache(root_path)
|
||||||
with chdir(root_path): # FIX: Don't change directory if possible.
|
with chdir(root_path): # FIX: Don't change directory if possible.
|
||||||
main(root_path, worker_count, is_sandboxed)
|
main(root_path, worker_count, is_sandboxed, editor_command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue