[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 9335953 44/62: Auto-completion: Faster fits pa
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 9335953 44/62: Auto-completion: Faster fits parse, use 'local' |
Date: |
Thu, 13 May 2021 22:20:52 -0400 (EDT) |
branch: master
commit 933595363937e98bd8e696f7ae8a0476bb20f582
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Auto-completion: Faster fits parse, use 'local'
With this commit, I added the '-q' option to 'astfits' program so it will
print less information, hence, it looks might be a bit faster.
Since we can use the 'local' declaration, I removed the 'unset' at the
end of functions and declared their variables as 'local' instead.
Also, there was a misleading typo in comments about return value of the
_gnuastro_autocomplete_plaintext_is_table function. It said the function
would return '1' if the given file is a table, on the contrary, it
returns '0', as it should by the conventions.
---
bin/table/completion.bash | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index 694b95d..b8270c6 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -95,15 +95,12 @@ _gnuastro_autocomplete_compgen(){
# suggestions
_gnuastro_autocomplete_list_fits_hdu(){
if [ -f "$1" ]; then
- list=("$(_gnuastro_autocomplete_get_fits_hdu "$1")")
+ local list=("$(_gnuastro_autocomplete_get_fits_hdu "$1")")
# A custom enhancement for the 'compgen' command. This version will
# have no problem with the dash sign '-'. Because sometimes the
# 'hdu' names might contain dash symbols in them. This ensures that
# all of them are suggested.
_gnuastro_autocomplete_compgen "${list[@]}" "$word"
- # TODO: If using `local` is allowed, remove the `unset` commands
- # and declare variables as `local` instead
- unset list
fi
}
@@ -129,7 +126,7 @@ _gnuastro_autocomplete_list_fits_names(){
# characters into '$COMPREPLY'.
local files=($(ls | grep -e "^$word" --color=never))
for f in ${files[*]} ; do
- if astfits $f &> /dev/null; then COMPREPLY+=("$f"); fi
+ if astfits "$f" -q &> /dev/null; then COMPREPLY+=("$f"); fi
done
}
@@ -210,7 +207,7 @@ _gnuastro_autocomplete_option_value(){
-# Return 1 if the given non-FITS file is a table.
+# Return 0 if the given non-FITS file is a table.
_gnuastro_autocomplete_plaintext_is_table(){
# For easy reading.
@@ -321,9 +318,8 @@ _gnuastro_autocomplete_get_fits_columns(){
# column names. If the file does not exist, pass.
_gnuastro_autocomplete_list_fits_columns(){
if [ -f "$1" ]; then
- list=("$(_gnuastro_autocomplete_get_fits_columns "$1")")
+ local list=("$(_gnuastro_autocomplete_get_fits_columns "$1")")
_gnuastro_autocomplete_compgen "${list[@]}"
- unset list
fi
}
@@ -346,12 +342,11 @@ _gnuastro_autocomplete_get_file(){
# short/long options as its first argument. In this case, autocompletion
# suggests both.
_gnuastro_autocomplete_list_options(){
- list=("$("$1" --help \
+ local list=("$("$1" --help \
| awk -v regex=" --+[a-zA-Z0-9]*=?" \
'match($0, regex) \
{print substr($0, RSTART, RLENGTH)}')")
_gnuastro_autocomplete_compgen "${list[@]}" "$word"
- unset list
}
- [gnuastro-commits] master 8150e1c 50/62: Auto-completion: Refactor FITS related functions, (continued)
- [gnuastro-commits] master 8150e1c 50/62: Auto-completion: Refactor FITS related functions, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master afadccf 52/62: Auto-completion: Call ..._last_table where needed, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 90f08c2 53/62: Auto-completion: Refactor ..._is_table function, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 4598eba 54/62: Auto-completion: clean re-implementation for Table, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 59669d9 61/62: Book: new section on known issues with Crop, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master b947f79 62/62: TAB completion: enabled in Fits program, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master acf58c1 58/62: TAB completion: now supported in ConvertType and Convolve, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 9ae830f 34/62: Table: Completion, replace double negative, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 7f1a203 35/62: Book: Autocompletion for developers example, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 6379566 36/62: Book: edits to the Bash auto-completion section, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 9335953 44/62: Auto-completion: Faster fits parse, use 'local',
Mohammad Akhlaghi <=
- [gnuastro-commits] master 284a32e 51/62: Auto-completion: Debug -i, improve performance, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e5707cd 28/62: Table: Completion, all options, update comments, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 88806f2 38/62: bin/table/completion.bash: improvements to find good table name, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 1bf469f 40/62: /bin/table/completion.bash: consider short opt '-i', Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e340452 42/62: Auto-completion: Minor polishing of the warning message, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master e444941 45/62: Auto-completion: Call astfits/asttable consistently, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 04ee1fe 46/62: Auto-completion: Suggest plaintext tables too, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master 3754f1b 47/62: Auto-completion: Human readable arguments, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master ea08fdb 49/62: Auto-completion: return value from last table, Mohammad Akhlaghi, 2021/05/13
- [gnuastro-commits] master ece1614 55/62: Auto complete: separated generic functions from Table's recipe, Mohammad Akhlaghi, 2021/05/13