[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pcmpl-args 690360006d 21/33: Fixed backspaces in man and g
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pcmpl-args 690360006d 21/33: Fixed backspaces in man and git completion |
Date: |
Mon, 31 Jan 2022 11:59:24 -0500 (EST) |
branch: elpa/pcmpl-args
commit 690360006df5019e37e3cc2e726844754d252eba
Author: Valeriy Litkovskyy <vlr.ltkvsk@protonmail.com>
Commit: Troy Hinckley <t.macman@gmail.com>
Fixed backspaces in man and git completion
Added two functions that remove backspaces from string and from argspecs.
Restored original pcmpl-args-default-man-function
Surrounded with backspaces removing function the results of
pcmpl-args-extract-argspecs-from-manpage and
pcmpl-args-git-extract-argspecs-from-help
---
pcmpl-args.el | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/pcmpl-args.el b/pcmpl-args.el
index a0cc5bae57..7d96b40d10 100644
--- a/pcmpl-args.el
+++ b/pcmpl-args.el
@@ -201,6 +201,24 @@ If the exit status is non-zero, an error is signaled."
(pcmpl-args-debug "!process-lines: %S %S" program args)
(apply 'process-lines program args))
+(defun pcmpl-args-unbackspace-string (string)
+ "Remove ^H characters from STRING."
+ (with-temp-buffer
+ (insert string)
+ (call-process-region (point-min) (point-max) "col" t t nil "-b")
+ (string-trim (buffer-string))))
+
+(defun pcmpl-args-unbackspace-argspecs (argspecs)
+ "Remove ^H characters from ARGSPECS."
+ (mapcar
+ (lambda (option)
+ (dolist (key '(:help option) option)
+ (let ((string (plist-get option key)))
+ (when string
+ (let ((new-string (pcmpl-args-unbackspace-string string)))
+ (setq option (plist-put option key new-string)))))))
+ argspecs))
+
;;; Option extraction from help text
@@ -793,8 +811,7 @@ insert its content into the current buffer.")
;; line, reducing the number of false positives that result from lines
;; starting with `-' that aren't really options.
(push "MANWIDTH=10000" process-environment)
- (pcmpl-args-process-file
- shell-file-name shell-command-switch (format "man %s | col -b"
(shell-quote-argument name)))))
+ (pcmpl-args-process-file "man" name)))
(defun pcmpl-args-extract-argspecs-from-manpage (name &rest args)
"Return a list of argspecs by parsing the manpage identified by NAME.
@@ -804,7 +821,8 @@ ARGS are passed to `pcmpl-args-parse-help-buffer'."
(erase-buffer)
(funcall pcmpl-args-man-function name)
(goto-char (point-min))
- (apply 'pcmpl-args-extract-argspecs-from-buffer args)))
+ (pcmpl-args-unbackspace-argspecs
+ (apply 'pcmpl-args-extract-argspecs-from-buffer args))))
(defun pcmpl-args-format-argspec (spec &optional short)
"Return a string for displaying SPEC."
@@ -3158,7 +3176,8 @@ options found in its man page."
(push "MANWIDTH=10000" process-environment)
(pcmpl-args-process-file "git" "help" "--man" "--" cmd)
(goto-char (point-min))
- (pcmpl-args-extract-argspecs-from-buffer)))))
+ (pcmpl-args-unbackspace-argspecs
+ (pcmpl-args-extract-argspecs-from-buffer))))))
(defun pcmpl-args-git-refs ()
(pcmpl-args-process-lines "git" "rev-parse" "--abbrev-ref" "--all"))
- [nongnu] branch elpa/pcmpl-args created (now 02ae18bda3), ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 4d74a0d768 11/33: Move README to README.org, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 690360006d 21/33: Fixed backspaces in man and git completion,
ELPA Syncer <=
- [nongnu] elpa/pcmpl-args 36139ba64f 20/33: Added pass completion, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 66276289e9 24/33: Fixed useless regexp, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 3e479c852b 03/33: Add link to github repo, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 886f0c4967 02/33: Add autoloads and packaging support, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 2ba03b3125 06/33: Add README and more documentation, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args f06b973c67 08/33: Merge pull request #1 from kozikow/master, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args c124d44bf4 09/33: Use cache for git completions, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 43f3daada7 19/33: Fix return outside of the block, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 7d444d5793 22/33: Update minor version, ELPA Syncer, 2022/01/31
- [nongnu] elpa/pcmpl-args 910f42cdbd 31/33: Fix package-lint warnings, ELPA Syncer, 2022/01/31