branch: elpa/pcmpl-args commit 886f0c496723082379a1346b8c6097af61297093 Author: Jonathan Waltman <jonathan.walt...@gmail.com> Commit: Jonathan Waltman <jonathan.walt...@gmail.com>
Add autoloads and packaging support --- pcmpl-args.el | 254 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 137 insertions(+), 117 deletions(-) diff --git a/pcmpl-args.el b/pcmpl-args.el index b75308ca2b..2200d56b5c 100644 --- a/pcmpl-args.el +++ b/pcmpl-args.el @@ -1,9 +1,12 @@ -;; pcmpl-args.el --- Enhanced shell command completion -*- lexical-binding: t -*- +;;; pcmpl-args.el --- Enhanced shell command completion -*- lexical-binding: t -*- ;; Copyright (C) 2012 Jonathan Waltman ;; Author: Jonathan Waltman <jonathan.walt...@gmail.com> -;; Keywords: +;; Keywords: abbrev completion convenience processes terminals unix +;; Version: 0.1 + +;; This file is not part of GNU Emacs. ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -1349,11 +1352,12 @@ mapping completions to their descriptions." (cadr cell)))) (puthash (propertize k 'help-echo v) (and (eq pcmpl-args-annotation-style 'long) - (pcmpl-args-truncate-string - (concat (pcmpl-args-pad-string "" (- maxwidth (length k))) - " " - (pcmpl-args-pad-string v (- 79 maxwidth (length k)))) - 79)) + (substring + (pcmpl-args-truncate-string + (concat (pcmpl-args-pad-string k maxwidth) + " " + (pcmpl-args-pad-string v (- 79 maxwidth))) 79) + (length k))) table)))) (maphash (lambda (k _v) (setq maxwidth (max maxwidth (length k)))) @@ -1362,20 +1366,24 @@ mapping completions to their descriptions." (maphash (lambda (k v) (puthash (propertize k 'help-echo v) (and (eq pcmpl-args-annotation-style 'long) - (pcmpl-args-truncate-string - (concat (pcmpl-args-pad-string "" (- maxwidth (length k))) - " " - (pcmpl-args-pad-string v (- 79 maxwidth (length k)))) - 79)) + (substring + (pcmpl-args-truncate-string + (concat (pcmpl-args-pad-string k maxwidth) + " " + (pcmpl-args-pad-string v (- 79 maxwidth))) 79) + (length k))) table)) alist-or-hash)) (setq alist-or-hash nil) (pcmpl-args-completion-table-with-metadata (append (or metadata '(metadata)) (list (cons 'annotation-function - (lambda (s) (or (gethash s table) - (gethash (pcomplete-unquote-argument s) - table)))))) + (lambda (s) + (or (gethash s table) + (let* ((us (pcomplete-unquote-argument s)) + (d (gethash us table))) + (assert (> (length s) (length us)) t) + (and d (substring d (- (length s) (length us)))))))))) table))) (defun pcmpl-args-pare-completion-table (new-table old-table) @@ -2887,11 +2895,6 @@ options found in its man page." (pcmpl-args-completion-table-with-annotations tbl `(metadata (category . hg-command)))))) -;; (defun pcmpl-args-hg-get-argspecs (hg-cmd) -;; (with-temp-buffer -;; (pcmpl-args-process-file "hg" "help" hg-cmd) -;; (pcmpl-args-extract-argspecs-from-buffer))) - (defun pcomplete/hg () (pcmpl-args-pcomplete (pcmpl-args-cached 'hg t @@ -2928,137 +2931,137 @@ options found in its man page." ;; Git completion (defvar pcmpl-args-git-commands - '(("annotate" "Annotate file lines with commit information.") - ("blame" "Show what revision and author last modified each line of a file.") - ("cherry" "Find commits not merged upstream.") - ("count-objects" "Count unpacked number of objects and their disk consumption.") - ("difftool" "Show changes using common diff tools.") - ("fsck" "Verifies the connectivity and validity of the objects in the database.") - ("get-tar-commit-id" "Extract commit ID from an archive created using git-archive.") - ("help" "display help information about git.") - ("instaweb" "Instantly browse your working repository in gitweb.") - ("merge-tree" "Show three-way merge without touching index.") - ("rerere" "Reuse recorded resolution of conflicted merges.") - ("rev-parse" "Pick out and massage parameters.") - ("show-branch" "Show branches and their commits.") - ("verify-tag" "Check the GPG signature of tags.") - ("whatchanged" "Show logs with difference each commit introduces.") - ("config" "Get and set repository or global options.") - ("fast-export" "Git data exporter.") - ("fast-import" "Backend for fast Git data importers.") - ("filter-branch" "Rewrite branches.") - ("lost-found" "(deprecated) Recover lost refs that luckily have not yet been pruned.") - ("mergetool" "Run merge conflict resolution tools to resolve merge conflicts.") - ("pack-refs" "Pack heads and tags for efficient repository access.") - ("prune" "Prune all unreachable objects from the object database.") - ("reflog" "Manage reflog information.") - ("relink" "Hardlink common objects in local repositories.") - ("remote" "manage set of tracked repositories.") - ("repack" "Pack unpacked objects in a repository.") - ("replace" "Create, list, delete refs to replace objects.") - ("repo-config" "(deprecated) Get and set repository or global options.") - ("archimport" "Import an Arch repository into git.") - ("cvsexportcommit" "Export a single commit to a CVS checkout.") - ("cvsimport" "Salvage your data out of another SCM people love to hate.") - ("cvsserver" "A CVS server emulator for git.") - ("imap-send" "Send a collection of patches from stdin to an IMAP folder.") - ("quiltimport" "Applies a quilt patchset onto the current branch.") - ("request-pull" "Generates a summary of pending changes.") - ("send-email" "Send a collection of patches as emails.") - ("svn" "Bidirectional operation between a Subversion repository and git.") - ("add" "Add file contents to the index.") + '(("add" "Add file contents to the index.") ("am" "Apply a series of patches from a mailbox.") + ("annotate" "Annotate file lines with commit information.") + ("apply" "Apply a patch to files and/or to the index.") + ("archimport" "Import an Arch repository into git.") ("archive" "Create an archive of files from a named tree.") ("bisect" "Find by binary search the change that introduced a bug.") + ("blame" "Show what revision and author last modified each line of a file.") ("branch" "List, create, or delete branches.") ("bundle" "Move objects and refs by archive.") + ("cat-file" "Provide content or type and size information for repository objects.") + ("check-attr" "Display gitattributes information.") + ("check-ref-format" "Ensures that a reference name is well formed.") ("checkout" "Checkout a branch or paths to the working tree.") + ("checkout-index" "Copy files from the index to the working tree.") + ("cherry" "Find commits not merged upstream.") ("cherry-pick" "Apply the change introduced by an existing commit.") ("citool" "Graphical alternative to git-commit.") ("clean" "Remove untracked files from the working tree.") ("clone" "Clone a repository into a new directory.") ("commit" "Record changes to the repository.") + ("commit-tree" "Create a new commit object.") + ("config" "Get and set repository or global options.") + ("count-objects" "Count unpacked number of objects and their disk consumption.") + ("cvsexportcommit" "Export a single commit to a CVS checkout.") + ("cvsimport" "Salvage your data out of another SCM people love to hate.") + ("cvsserver" "A CVS server emulator for git.") + ("daemon" "A really simple server for git repositories.") ("describe" "Show the most recent tag that is reachable from a commit.") ("diff" "Show changes between commits, commit and working tree, etc.") + ("diff-files" "Compares files in the working tree and the index.") + ("diff-index" "Compares content and mode of blobs between the index and repository.") + ("diff-tree" "Compares the content and mode of blobs found via two tree objects.") + ("difftool" "Show changes using common diff tools.") + ("fast-export" "Git data exporter.") + ("fast-import" "Backend for fast Git data importers.") ("fetch" "Download objects and refs from another repository.") + ("fetch-pack" "Receive missing objects from another repository.") + ("filter-branch" "Rewrite branches.") + ("fmt-merge-msg" "Produce a merge commit message.") + ("for-each-ref" "Output information on each ref.") ("format-patch" "Prepare patches for e-mail submission.") + ("fsck" "Verifies the connectivity and validity of the objects in the database.") ("gc" "Cleanup unnecessary files and optimize the local repository.") + ("get-tar-commit-id" "Extract commit ID from an archive created using git-archive.") ("grep" "Print lines matching a pattern.") ("gui" "A portable graphical interface to Git.") + ("hash-object" "Compute object ID and optionally creates a blob from a file.") + ("help" "display help information about git.") + ("http-backend" "Server side implementation of Git over HTTP.") + ("http-fetch" "Download from a remote git repository via HTTP.") + ("http-push" "Push objects over HTTP/DAV to another repository.") + ("imap-send" "Send a collection of patches from stdin to an IMAP folder.") + ("index-pack" "Build pack index file for an existing packed archive.") ("init" "Create an empty git repository or reinitialize an existing one.") + ("instaweb" "Instantly browse your working repository in gitweb.") ("log" "Show commit logs.") + ("lost-found" "(deprecated) Recover lost refs that luckily have not yet been pruned.") + ("ls-files" "Show information about files in the index and the working tree.") + ("ls-remote" "List references in a remote repository.") + ("ls-tree" "List the contents of a tree object.") + ("mailinfo" "Extracts patch and authorship from a single e-mail message.") + ("mailsplit" "Simple UNIX mbox splitter program.") ("merge" "Join two or more development histories together.") + ("merge-base" "Find as good common ancestors as possible for a merge.") + ("merge-file" "Run a three-way file merge.") + ("merge-index" "Run a merge for files needing merging.") + ("merge-one-file" "The standard helper program to use with git-merge-index.") + ("merge-tree" "Show three-way merge without touching index.") + ("mergetool" "Run merge conflict resolution tools to resolve merge conflicts.") + ("mktag" "Creates a tag object.") + ("mktree" "Build a tree-object from ls-tree formatted text.") ("mv" "Move or rename a file, a directory, or a symlink.") + ("name-rev" "Find symbolic names for given revs.") ("notes" "Add/inspect commit notes.") + ("pack-objects" "Create a packed archive of objects.") + ("pack-redundant" "Find redundant pack files.") + ("pack-refs" "Pack heads and tags for efficient repository access.") + ("parse-remote" "Routines to help parsing remote repository access parameters.") + ("patch-id" "Compute unique ID for a patch.") + ("peek-remote" "(deprecated) List the references in a remote repository.") + ("prune" "Prune all unreachable objects from the object database.") + ("prune-packed" "Remove extra objects that are already in pack files.") ("pull" "Fetch from and merge with another repository or a local branch.") ("push" "Update remote refs along with associated objects.") + ("quiltimport" "Applies a quilt patchset onto the current branch.") + ("read-tree" "Reads tree information into the index.") ("rebase" "Forward-port local commits to the updated upstream head.") + ("receive-pack" "Receive what is pushed into the repository.") + ("reflog" "Manage reflog information.") + ("relink" "Hardlink common objects in local repositories.") + ("remote" "manage set of tracked repositories.") + ("repack" "Pack unpacked objects in a repository.") + ("replace" "Create, list, delete refs to replace objects.") + ("repo-config" "(deprecated) Get and set repository or global options.") + ("request-pull" "Generates a summary of pending changes.") + ("rerere" "Reuse recorded resolution of conflicted merges.") ("reset" "Reset current HEAD to the specified state.") + ("rev-list" "Lists commit objects in reverse chronological order.") + ("rev-parse" "Pick out and massage parameters.") ("revert" "Revert an existing commit.") ("rm" "Remove files from the working tree and from the index.") + ("send-email" "Send a collection of patches as emails.") + ("send-pack" "Push objects over git protocol to another repository.") + ("sh-setup" "Common git shell script setup code.") + ("shell" "Restricted login shell for GIT-only SSH access.") ("shortlog" "Summarize 'git log' output.") ("show" "Show various types of objects.") + ("show-branch" "Show branches and their commits.") + ("show-index" "Show packed archive index.") + ("show-ref" "List references in a local repository.") ("stash" "Stash the changes in a dirty working directory away.") ("status" "Show the working tree status.") + ("stripspace" "Filter out empty lines.") ("submodule" "Initialize, update or inspect submodules.") + ("svn" "Bidirectional operation between a Subversion repository and git.") + ("symbolic-ref" "Read and modify symbolic refs.") ("tag" "Create, list, delete or verify a tag object signed with GPG.") - ("cat-file" "Provide content or type and size information for repository objects.") - ("diff-files" "Compares files in the working tree and the index.") - ("diff-index" "Compares content and mode of blobs between the index and repository.") - ("diff-tree" "Compares the content and mode of blobs found via two tree objects.") - ("for-each-ref" "Output information on each ref.") - ("ls-files" "Show information about files in the index and the working tree.") - ("ls-remote" "List references in a remote repository.") - ("ls-tree" "List the contents of a tree object.") - ("merge-base" "Find as good common ancestors as possible for a merge.") - ("name-rev" "Find symbolic names for given revs.") - ("pack-redundant" "Find redundant pack files.") - ("rev-list" "Lists commit objects in reverse chronological order.") - ("show-index" "Show packed archive index.") - ("show-ref" "List references in a local repository.") ("tar-tree" "(deprecated) Create a tar archive of the files in the named tree object.") ("unpack-file" "Creates a temporary file with a blob's contents.") - ("var" "Show a git logical variable.") - ("verify-pack" "Validate packed git archive files.") - ("apply" "Apply a patch to files and/or to the index.") - ("checkout-index" "Copy files from the index to the working tree.") - ("commit-tree" "Create a new commit object.") - ("hash-object" "Compute object ID and optionally creates a blob from a file.") - ("index-pack" "Build pack index file for an existing packed archive.") - ("merge-file" "Run a three-way file merge.") - ("merge-index" "Run a merge for files needing merging.") - ("mktag" "Creates a tag object.") - ("mktree" "Build a tree-object from ls-tree formatted text.") - ("pack-objects" "Create a packed archive of objects.") - ("prune-packed" "Remove extra objects that are already in pack files.") - ("read-tree" "Reads tree information into the index.") - ("symbolic-ref" "Read and modify symbolic refs.") ("unpack-objects" "Unpack objects from a packed archive.") ("update-index" "Register file contents in the working tree to the index.") ("update-ref" "Update the object name stored in a ref safely.") - ("write-tree" "Create a tree object from the current index.") - ("check-attr" "Display gitattributes information.") - ("check-ref-format" "Ensures that a reference name is well formed.") - ("fmt-merge-msg" "Produce a merge commit message.") - ("mailinfo" "Extracts patch and authorship from a single e-mail message.") - ("mailsplit" "Simple UNIX mbox splitter program.") - ("merge-one-file" "The standard helper program to use with git-merge-index.") - ("patch-id" "Compute unique ID for a patch.") - ("peek-remote" "(deprecated) List the references in a remote repository.") - ("sh-setup" "Common git shell script setup code.") - ("stripspace" "Filter out empty lines.") - ("http-fetch" "Download from a remote git repository via HTTP.") - ("http-push" "Push objects over HTTP/DAV to another repository.") - ("parse-remote" "Routines to help parsing remote repository access parameters.") - ("receive-pack" "Receive what is pushed into the repository.") - ("shell" "Restricted login shell for GIT-only SSH access.") + ("update-server-info" "Update auxiliary info file to help dumb servers.") ("upload-archive" "Send archive back to git-archive.") ("upload-pack" "Send objects packed back to git-fetch-pack.") - ("daemon" "A really simple server for git repositories.") - ("fetch-pack" "Receive missing objects from another repository.") - ("http-backend" "Server side implementation of Git over HTTP.") - ("send-pack" "Push objects over git protocol to another repository.") - ("update-server-info" "Update auxiliary info file to help dumb servers."))) + ("var" "Show a git logical variable.") + ("verify-pack" "Validate packed git archive files.") + ("verify-tag" "Check the GPG signature of tags.") + ("whatchanged" "Show logs with difference each commit introduces.") + ("write-tree" "Create a tree object from the current index."))) (defun pcmpl-args-git-commands () (pcmpl-args-cached 'git-commands t @@ -3304,7 +3307,6 @@ options found in its man page." (defalias 'pcomplete/emacs 'pcmpl-args-pcomplete-on-man) (defalias 'pcomplete/gawk 'pcmpl-args-pcomplete-on-man) (defalias 'pcomplete/gperf 'pcmpl-args-pcomplete-on-man) -(defalias 'pcomplete/id 'pcmpl-args-pcomplete-on-man) (defalias 'pcomplete/indent 'pcmpl-args-pcomplete-on-man) (defalias 'pcomplete/locate 'pcmpl-args-pcomplete-on-man) (defalias 'pcomplete/ld 'pcmpl-args-pcomplete-on-man) @@ -3389,9 +3391,10 @@ will print completions for `ls -'." "" (or (funcall afun c) ""))) (terpri)))) -(defun pcmpl-args--debug-pcomplete-commands (&optional regexp) +(defun pcmpl-args--debug-pcomplete-commands (&optional regexp verbose) "Collect statistics for pcomplete/ commands." - (interactive (list (read-regexp "Debug pcomplete/ commands matching regexp"))) + (interactive (list (read-regexp "Debug pcomplete/ commands matching regexp") + current-prefix-arg)) (let* ((pcmpl-args-debug t) (regexp (or regexp "")) (cmds @@ -3434,7 +3437,7 @@ will print completions for `ls -'." (setq opt-cap-data (pcmpl-args--debug-completion-at-point-data (concat cmd " -")) opt-comps (all-completions "-" (elt opt-cap-data 2)) arg-cap-data (pcmpl-args--debug-completion-at-point-data (concat cmd " ")) - arg-comps (all-completions " " (elt arg-cap-data 2))) + arg-comps (all-completions "" (elt arg-cap-data 2))) (error (push (list (car cmds) opt-cap-data err) failed-cmds))) (let ((long 0) @@ -3461,9 +3464,10 @@ will print completions for `ls -'." c)))) new-raw-argspecs)) (setq new-raw-argspecs (nreverse new-raw-argspecs) new-argspecs (pcmpl-args-make-argspecs new-raw-argspecs)) - (insert - (pcmpl-args-format-argspecs new-argspecs) - "\n\n") + (when verbose + (insert + (pcmpl-args-format-argspecs new-argspecs) + "\n\n")) (let ((new-long 0) (new-short 0)) (dolist (spec new-argspecs) @@ -3557,8 +3561,24 @@ will print completions for `ls -'." ;; (elp-restore-all) ;; (elp-instrument-package "pcmpl-") ;; (elp-instrument-package "pcomplete-") -;; (elp-instrument-package "completion--twq") ;; t) + +;;; Autoload + +;; ;; Eval to generate autoloads. +;; (let (accum) +;; (save-excursion +;; (goto-char (point-min)) +;; (while (re-search-forward "^ *(\\(defun\\|defalias\\) +'?\\(pcomplete/.+?\\) " nil t) +;; (assert (fboundp (intern-soft (match-string-no-properties 2))) t) +;; (push (match-string-no-properties 2) accum)) +;; (setq accum (nreverse accum)) +;; (assert (= (length accum) (length (delete-dups (copy-sequence accum)))) t)) +;; (insert (format "\n\n;;;###autoload (dolist (func '(%s)) (autoload func \"pcmpl-args\"))\n" +;; (mapconcat 'identity accum " ")))) + +;;;###autoload (dolist (func '(pcomplete/chgrp pcomplete/chmod pcomplete/chown pcomplete/chroot pcomplete/cp pcomplete/date pcomplete/dd pcomplete/dir pcomplete/echo pcomplete/env pcomplete/false pcomplete/groups pcomplete/id pcomplete/ln pcomplete/ls pcomplete/mv pcomplete/nice pcomplete/nohup pcomplete/printenv pcomplete/printf pcomplete/rm pcomplete/rmdir pcomplete/sort pcomplete/stat pcomplete/test pcomplete/true pcomplete/vdir pcomplete/basename pcomplete/cat pcomplete/cksum pcomple [...] + (provide 'pcmpl-args) ;;; pcmpl-args.el ends here