[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-hgcmd 323b4ab 41/87: Option to skip data on error ch
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vc-hgcmd 323b4ab 41/87: Option to skip data on error channel |
Date: |
Sat, 5 Jun 2021 16:11:42 -0400 (EDT) |
branch: externals/vc-hgcmd
commit 323b4ab7336e5b2c1949b41f3268aae14c0ded05
Author: muffinmad <andreyk.mad@gmail.com>
Commit: muffinmad <andreyk.mad@gmail.com>
Option to skip data on error channel
---
vc-hgcmd.el | 48 +++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/vc-hgcmd.el b/vc-hgcmd.el
index 98c7c46..3cd74e3 100644
--- a/vc-hgcmd.el
+++ b/vc-hgcmd.el
@@ -5,7 +5,7 @@
;; Author: Andrii Kolomoiets <andreyk.mad@gmail.com>
;; Keywords: vc
;; URL: https://github.com/muffinmad/emacs-vc-hgcmd
-;; Package-Version: 1.3.10
+;; Package-Version: 1.3.11
;; Package-Requires: ((emacs "25.1"))
;; This file is NOT part of GNU Emacs.
@@ -177,7 +177,7 @@ same branch was merged."
(defvar vc-hgcmd--process-buffers-by-dir (make-hash-table :test #'equal))
-(cl-defstruct (vc-hgcmd--command (:copier nil)) command output-buffer
result-code wait callback callback-args)
+(cl-defstruct (vc-hgcmd--command (:copier nil)) command output-buffer
skip-error result-code wait callback callback-args)
(defvar-local vc-hgcmd--current-command nil
"Current running hgcmd command. Future commands will wait until the current
command will finish.")
@@ -233,12 +233,13 @@ Insert output to process buffer and check if amount of
data is enought to parse
(let ((channel (car data))
(data (cdr data)))
(cond ((memq channel '(?o ?e ?d))
- (let ((output-buffer
(vc-hgcmd--command-output-buffer current-command)))
- (when (or (stringp output-buffer) (buffer-live-p
output-buffer))
- (with-current-buffer output-buffer
- (let ((inhibit-read-only t))
- (goto-char (point-max))
- (insert data))))))
+ (unless (and (eq channel ?e)
(vc-hgcmd--command-skip-error current-command))
+ (let ((output-buffer
(vc-hgcmd--command-output-buffer current-command)))
+ (when (or (stringp output-buffer)
(buffer-live-p output-buffer))
+ (with-current-buffer output-buffer
+ (let ((inhibit-read-only t))
+ (goto-char (point-max))
+ (insert data)))))))
((eq channel ?r)
(setf (vc-hgcmd--command-result-code
current-command) data)
(setq vc-hgcmd--current-command nil)
@@ -362,10 +363,10 @@ Insert output to process buffer and check if amount of
data is enought to parse
(accept-process-output process 0.1 nil t)))
t))))
-(defun vc-hgcmd-command (&rest command)
- "Run hg COMMAND and return it's output."
+(defun vc-hgcmd--command (skip-error &rest command)
+ "Run hg COMMAND and return it's output. If SKIP-ERROR is non nil data on
error channel will be omited."
(with-temp-buffer
- (let ((cmd (make-vc-hgcmd--command :command command :output-buffer
(current-buffer) :wait t)))
+ (let ((cmd (make-vc-hgcmd--command :command command :output-buffer
(current-buffer) :wait t :skip-error skip-error)))
(when (vc-hgcmd--run-command cmd)
(let ((result (string-trim-right (buffer-string))))
;; TODO min result code for each command that is not error
@@ -378,6 +379,10 @@ Insert output to process buffer and check if amount of
data is enought to parse
(when (> (length result) 0)
result)))))))
+(defun vc-hgcmd-command (&rest command)
+ "Run hg COMMAND and return it's output."
+ (apply #'vc-hgcmd--command (nconc (list nil) command)))
+
(defun vc-hgcmd-command-to-buffer (buffer &rest command)
"Send output of COMMAND to BUFFER and wait COMMAND to finish."
(vc-setup-buffer buffer)
@@ -425,9 +430,6 @@ Insert output to process buffer and check if amount of data
is enought to parse
"Return tags list."
(split-string (vc-hgcmd-command "tags" "-q") "\n"))
-(defconst vc-hgcmd--no-file-re
- ".+: No such file or directory$")
-
(defun vc-hgcmd--file-relative-name (file)
"Return FILE file name relative to vc root."
(file-relative-name file (vc-hgcmd-root file)))
@@ -457,8 +459,8 @@ Insert output to process buffer and check if amount of data
is enought to parse
(defun vc-hgcmd-state (file)
"State for FILE."
- (let ((out (vc-hgcmd-command "status" "-A" (vc-hgcmd--file-relative-name
file))))
- (when (and out (null (string-match-p vc-hgcmd--no-file-re out)))
+ (let ((out (vc-hgcmd--command t "status" "-A" (vc-hgcmd--file-relative-name
file))))
+ (when out
(let ((state (cdr (assoc (aref out 0) vc-hgcmd--translation-status))))
(if (and (eq state 'edited) (vc-hgcmd--file-unresolved-p file))
'conflict
@@ -470,12 +472,11 @@ Insert output to process buffer and check if amount of
data is enought to parse
(conflicted (vc-hgcmd-conflicted-files)))
(goto-char (point-min))
(while (not (eobp))
- (unless (looking-at vc-hgcmd--no-file-re)
- (let* ((file (buffer-substring-no-properties (+ (point) 2)
(line-end-position)))
- (state (if (member file conflicted)
- 'conflict
- (cdr (assoc (char-after)
vc-hgcmd--translation-status)))))
- (push (list file state nil) result)))
+ (let* ((file (buffer-substring-no-properties (+ (point) 2)
(line-end-position)))
+ (state (if (member file conflicted)
+ 'conflict
+ (cdr (assoc (char-after)
vc-hgcmd--translation-status)))))
+ (push (list file state nil) result))
(forward-line))
(funcall update-function result)))
@@ -490,7 +491,8 @@ Insert output to process buffer and check if amount of data
is enought to parse
:command command
:output-buffer (current-buffer)
:callback #'vc-hgcmd--dir-status-callback
- :callback-args update-function))))
+ :callback-args update-function
+ :skip-error t))))
(defun vc-hgcmd--extra-header (name value)
"Format NAME and VALUE as dir extra header."
- [elpa] externals/vc-hgcmd 39dddda 22/87: Use relative filename on check status, (continued)
- [elpa] externals/vc-hgcmd 39dddda 22/87: Use relative filename on check status, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd d9bc82c 09/87: fixed typo, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd c05d560 16/87: melpa-stable badge, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3b2d060 17/87: Show command output on command error, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 876f7cb 20/87: Handle nil on reading parents, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 15c2c27 23/87: Communication with tty process, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 0bd38be 24/87: User parent info from summary in there are no log, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd e6f1105 25/87: Use relative file names for all commands, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f093b75 34/87: Message if hg command is running when running another, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f92c39b 40/87: Fixed regexp, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 323b4ab 41/87: Option to skip data on error channel,
Stefan Monnier <=
- [elpa] externals/vc-hgcmd d439b43 42/87: Running command indicator in output buffer mode line, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3f8c60b 45/87: Create output buffer before actually running command, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 6379ef2 50/87: process-environment order, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f87a21d 54/87: next/previous revison respects files, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd adb7cb5 11/87: directories are always registered, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd d30560d 14/87: Melpa badge, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 7e4fc39 19/87: Custom function to edit initial commit message, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 4c6b2e7 32/87: Kill process buffer when process terminates, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 646c9b7 35/87: inline some functions; handle killed output buffers, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 64af3c5 38/87: make hgcmd process buffer hidden, Stefan Monnier, 2021/06/05