redo _zsh_highlight__function_callable_p
This commit is contained in:
		
							parent
							
								
									38477f2a3d
								
							
						
					
					
						commit
						d4ab7e51d2
					
				|  | @ -49,6 +49,25 @@ if true; then | ||||||
|   fi |   fi | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | # This function takes a single argument F and returns True iff F is an autoload stub. | ||||||
|  | _zsh_highlight__function_is_autoload_stub_p() { | ||||||
|  |   if (( ${+functions} )); then | ||||||
|  |     ## zsh/parameter is available | ||||||
|  |     #(( ${+functions[$1]} )) && | ||||||
|  |     [[ "$functions[$1]" == *"builtin autoload -X" ]] | ||||||
|  |   else | ||||||
|  |     ## zsh/parameter isn't available | ||||||
|  |     #[[ $(type -wa -- "$1") == *'function'* ]] && | ||||||
|  |     [[ "${${(@f)"$(which -- "$1")"}[2]}" == $'\t'$histchars[3]' undefined' ]] | ||||||
|  |   fi | ||||||
|  |   # Do nothing here: return the exit code of the if. | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | # Return True iff the argument denotes a function name. | ||||||
|  | _zsh_highlight__is_function_p() { | ||||||
|  |   (( ${+functions[$1]} )) || [[ $(type -wa -- "$1") == *'function'* ]] | ||||||
|  | } | ||||||
|  | 
 | ||||||
| # This function takes a single argument F and returns True iff F denotes the | # This function takes a single argument F and returns True iff F denotes the | ||||||
| # name of a callable function.  A function is callable if it is fully defined | # name of a callable function.  A function is callable if it is fully defined | ||||||
| # or if it is marked for autoloading and autoloading it at the first call to it | # or if it is marked for autoloading and autoloading it at the first call to it | ||||||
|  | @ -57,23 +76,21 @@ fi | ||||||
| # | # | ||||||
| # See users/21671 http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=21671 | # See users/21671 http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=21671 | ||||||
| _zsh_highlight__function_callable_p() { | _zsh_highlight__function_callable_p() { | ||||||
|   { # Trenary condition: if the zle/parameter module is available, ... |   if _zsh_highlight__is_function_p "$1" && | ||||||
|     if (( ${+functions} )); then |      ! _zsh_highlight__function_is_autoload_stub_p "$1" | ||||||
|       # ... then use it to make the decision, ... |   then | ||||||
|       if (( ${+functions[$1]} )); then |     # Already fully loaded. | ||||||
|         [[ "$functions[$1]" != *"builtin autoload -X" ]] \ |     return 0 # true | ||||||
|         || |   else | ||||||
|         ( unfunction -- "$1" && autoload -U +X -- "$1" 2>/dev/null ) |     # "$1" is either an autoload stub, or not a function at all. | ||||||
|       else |     # | ||||||
|         (                       autoload -U +X -- "$1" 2>/dev/null ) |     # Use a subshell to avoid affecting the calling shell. | ||||||
|       fi |     # | ||||||
|     else |     # We expect 'autoload +X' to return non-zero if it fails to fully load | ||||||
|       # ... otherwise, use a fallback approach. |     # the function. | ||||||
|       autoload -U +X -- "$1" 2>/dev/null |     ( autoload -U +X -- "$1" 2>/dev/null ) | ||||||
|       [[ "${${(@f)"$(which -- "$1")"}[2]}" != $'\t'$histchars[3]' undefined' ]] |     return $? | ||||||
|     fi |   fi | ||||||
|   } |  | ||||||
|   # Do nothing here!  We return the exit code of the if. |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| integer zsh_highlight_use_redrawhook | integer zsh_highlight_use_redrawhook | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue