zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: PATCH: improved completion in math context
Date: Fri, 15 Mar 2013 21:42:01 +0000	[thread overview]
Message-ID: <20130315214201.4233b3b0@pws-pc.ntlworld.com> (raw)

Index: Completion/Zsh/Context/_math
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_math,v
retrieving revision 1.1
diff -p -u -r1.1 _math
--- Completion/Zsh/Context/_math	2 Apr 2001 11:23:46 -0000	1.1
+++ Completion/Zsh/Context/_math	15 Mar 2013 21:41:12 -0000
@@ -9,4 +9,6 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; th
   SUFFIX="${SUFFIX%%[^a-zA-Z0-9_]*}"
 fi
 
-_parameters -g '(integer|float)*' || _parameters
+_alternative 'integer-parameters:integer parameter: _math_params' \
+    'user-math-functions:user math function: _user_math_func' \
+    'module-math-functions:math function from zsh/mathfunc: _module_math_func'
Index: Completion/Zsh/Context/_zcalc_line
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_zcalc_line,v
retrieving revision 1.2
diff -p -u -r1.2 _zcalc_line
--- Completion/Zsh/Context/_zcalc_line	13 Jun 2008 14:27:37 -0000	1.2
+++ Completion/Zsh/Context/_zcalc_line	15 Mar 2013 21:41:12 -0000
@@ -13,7 +13,7 @@ _zcalc_line_escapes() {
     "eng:engineering (power of 1000) output format"
     "raw:raw output format"
     "local:make variables local"
-    "function:define math function"
+    "function:define math function (also \:func or \:f)"
   )
   cmds=("\:"${^cmds})
   _describe -t command-escapes "command escapes" cmds -Q
Index: Completion/Zsh/Type/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/.distfiles,v
retrieving revision 1.4
diff -p -u -r1.4 .distfiles
--- Completion/Zsh/Type/.distfiles	10 Nov 2008 15:28:42 -0000	1.4
+++ Completion/Zsh/Type/.distfiles	15 Mar 2013 21:41:12 -0000
@@ -15,10 +15,13 @@ _jobs
 _jobs_bg
 _jobs_fg
 _limits
+_math_params
+_module_math_func
 _options
 _options_set
 _options_unset
 _parameters
 _suffix_alias_files
+_user_math_func
 _vars
 '
Index: Completion/Zsh/Type/_math_params
===================================================================
RCS file: Completion/Zsh/Type/_math_params
diff -N Completion/Zsh/Type/_math_params
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Type/_math_params	15 Mar 2013 21:41:12 -0000
@@ -0,0 +1,3 @@
+#autoload
+
+_parameters -g '(integer|float)*' || _parameters
Index: Completion/Zsh/Type/_module_math_func
===================================================================
RCS file: Completion/Zsh/Type/_module_math_func
diff -N Completion/Zsh/Type/_module_math_func
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Type/_module_math_func	15 Mar 2013 21:41:12 -0000
@@ -0,0 +1,9 @@
+#autoload
+
+local expl
+local -a funcs
+
+funcs=(${${${(f)"$(zmodload -Fl zsh/mathfunc 2>/dev/null)"}:#^+f:*}##+f:})
+
+_wanted module-math-functions expl 'math function from zsh/mathfunc' \
+    compadd -S '(' "$@" -a funcs
Index: Completion/Zsh/Type/_user_math_func
===================================================================
RCS file: Completion/Zsh/Type/_user_math_func
diff -N Completion/Zsh/Type/_user_math_func
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Zsh/Type/_user_math_func	15 Mar 2013 21:41:12 -0000
@@ -0,0 +1,9 @@
+#autoload
+
+local expl
+local -a funcs
+
+funcs=(${${${(f)"$(functions -M)"}##functions -M }%% *})
+
+_wanted user-math-functions expl 'user math function' \
+    compadd -S '(' "$@" -a funcs

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


                 reply	other threads:[~2013-03-15 21:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130315214201.4233b3b0@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).