Archived
1
0
Fork 0

update(orgmode): add dependancy

This commit is contained in:
rick 2021-10-01 00:04:18 +02:00
parent 607e1e5b52
commit 66cf8f0b6a
Signed by: Rick
GPG key ID: 2B593F087240EE99
8 changed files with 5742 additions and 0 deletions

View file

@ -39,6 +39,7 @@ Le fichier vimrc.bepo est une configuration spéciale pour les claviers bépo. V
* [Syntaxe SourcePawn](https://github.com/withgod/vim-sourcepawn) : Coloration syntaxique et support pour le SourcePawn.
* [Vim OrgMode](https://vimawesome.com/plugin/vim-orgmode) : pour avoir un support du OrgMode d'Emacs dans Vim (n'a pas cependant toutes les fonctionnalités et n'est plus maintenu). Il nécessite quelques plugins en plus qui sont listés ci dessous :
* [SpeedDating](https://vimawesome.com/plugin/speeddating-vim) : incrémenter des dates avec C-A
* [Universal Text Linking](http://www.vim.org/scripts/script.php?script_id=293) : lier les liens textes
### Plugins de lancienne version de ce dépôt qui seront remis plus tard

170
autoload/utl_lib.vim Normal file
View file

@ -0,0 +1,170 @@
" ------------------------------------------------------------------------------
" File: autoload/utl_lib.vim -- Finish installation and
" data migration support
" Part of the Utl plugin, see ../plugin/utl.vim
" Author: Stefan Bittner <stb@bf-consulting.de>
" Licence: This program is free software; you can redistribute it and/or
" modify it under the terms of the GNU General Public License.
" See http://www.gnu.org/copyleft/gpl.txt
" Version: utl 3.0a
" ------------------------------------------------------------------------------
"-------------------------------------------------------------------------------
" Intended to finish installation after Utl 3.0a files have been installed
" by UseVimball. Will automatically be called after UseVimball in
" utl_3_0a.vba. But can be called at any later time or can be called multiple
" times. As an autoload function it can be called directly from within
" :so utl_3_0a.vba without starting a new Vim instance.
"
" - Deletes any existing obsolete files: plugin/utl_arr.vim, doc/utl_ref.txt
" - Data migration: Checks for utl_2.0 configuration variables and print
" instructions to user how to migrate them.
"
" Note: Utl 3.0a installation saved file plugin/utl_rc.vim to
" plugin/utl_old_rc.vim prior to Utl 3.0a installation (Preinstall). So the
" old variables remain and will be visible in new Vim instance.
"
function! utl_lib#Postinstall()
echo "----------------------------------------------------------------------"
echo "Info: Start of Utl 3.0a post installation."
echo " This will handle relicts of any previously installed Utl version"
echo "\n"
if ! exists("g:utl_vim")
echo "Info: No previously installed Utl version found (variable g:utl_vim)"
echo " does not exist). Nothing to do at all."
if exists("g:utl_rc_vim")
echo "\n"
echo "Warning: But file ".g:utl_rc_vim." still exists"
echo " You should remove it from the plugin directory"
endif
echo "\n"
echo " To start with Utl open a new Vim, type:"
echo " :help utl"
echo " and follow the live examples"
echo "\n"
echo " End of Utl 3.0a post installation"
echo "----------------------------------------------------------------------\n"
call input("<Hit Return to continue>")
return
endif
"--- 2. Delete obsolete Utl 2.0 files
if exists("g:utl_arr_vim")
if filereadable(g:utl_arr_vim)
if delete(g:utl_arr_vim)==0
echo "Info: obsolete Utl 2.0 file ".g:utl_arr_vim." deleted successfully"
else
echohl WarningMsg
echo "Warning: Could not delete obsolete Utl 2.0 file".g:utl_arr_vim."."
echo " This does not affect proper function but you might want to"
echo " delete it manually in order to cleanup your plugin directory"
echohl None
endif
else
echo "Warning: no obsolete Utl 2.0 file ".g:utl_arr_vim." found"
endif
else
echo "Warning: variable g:utl_arr_vim not found. Inconsistent installation"
endif
if exists("g:utl_vim") " no variable for utl_ref, so start from utl.vim
let utl_ref_txt = fnamemodify(g:utl_vim, ":p:h:h") . "/doc/utl_ref.txt"
if filereadable(utl_ref_txt)
if delete(utl_ref_txt)==0
echo "Info: obsolete Utl 2.0 file ".utl_ref_txt." deleted successfully"
else
echohl WarningMsg
echo "Warning: Could not delete obsolete Utl 2.0 file ".utl_ref_txt
echo " but you might want to delete it manually to avoid garbage"
echo " docs / help tags"
echohl None
endif
else
echo "Warning: no obsolete Utl 2.0 file ".utl_ref_txt." found"
endif
endif
"--- 3. Check for Utl V2.0 variables
" The user might want to migrate these to Utl 2.1 variable names
" g:utl_rc_xxx -> g:utl_cfg_xxx
" g:utl_config_highl_urls -> g:utl_opt_highlight_urls
" g:utl_mt_xxx -> utl_cfg_mth__xxx
let varMap = {}
if exists("g:utl_rc_app_mailer")
let varMap['g:utl_rc_app_mailer'] = 'g:utl_cfg_hdl_scm_mailto'
endif
if exists("g:utl_rc_app_browser")
let varMap['g:utl_rc_app_browser'] = 'g:utl_cfg_hdl_scm_http'
endif
if exists("g:utl_config_highl")
let varMap['g:utl_config_highl'] = 'g:utl_opt_highlight_urls'
endif
" All utl_mt_ variables. Get them by capturing the ':let' output
redir => redirBuf
silent let
redir END
let line=split(redirBuf)
let prefix='utl_mt_'
for item in line
if item=~ '^'.prefix
let suffix = strpart(item, strlen(prefix))
let newName = 'utl_cfg_hdl_mt_'.suffix
let varMap['utl_mt_'.suffix] = newName
endif
endfor
if ! empty(varMap)
echo "\n"
echohl WarningMsg
echo "Warning: The following Vim variable(s) from a previously installed"
echo " Utl version have been detected. You might a) want to rename"
echo " them to the new Utl version 3.0a names as given in the table below."
echo " Or you might b) want just delete the old variables."
echo "\n"
echo " If you don't care, then choose b), i.e. just remove those variables"
echo " from your vimrc or delete utl_rc_old.vim (which possibly has been"
echo " created during preinstall (see second line in utl_3_0a.vba)). This is"
echo " not a bad choice since Utl 3.0 provides a generic handler variable"
echo " which discharges you from maintaining specific handler variables for"
echo " each file type."
echohl None
else
echo "Info: No variables of a previous Utl installation detected."
echo " So nothing no further instructions for moving them away needed."
endif
for key in sort(keys(varMap))
echo printf(" %-40s -> %s", key, varMap[key])
endfor
if ! empty(varMap)
echo "\n"
endif
echo "\n"
echo "Info: You can perform post installation again anytime with the command:"
echo " :call utl_lib#Postinstall()\n"
echo " You can also just install again by :source'ing Utl_3_0a.vba"
echo "\n"
echo " You should move the possibly created file plugin/utl_old_rc.vim out of"
echo " the way when done with data migration. I.e. delete it or rename it to"
echo " other file name extension than .vim or move it away from the plugin"
echo " directory."
echo "\n"
echo " To start with Utl open a new Vim and type:"
echo " :help utl"
echo "\n"
echo "Info: End of Utl 3.0a post installation"
echo "----------------------------------------------------------------------\n"
call input("<Hit Return to continue>")
endfunction

100
doc/tags Normal file
View file

@ -0,0 +1,100 @@
Utl-chgOverview utl_usr.txt /*Utl-chgOverview*
utl utl_usr.txt /*utl*
utl-absDontCombine utl_usr.txt /*utl-absDontCombine*
utl-btSample utl_usr.txt /*utl-btSample*
utl-changes utl_usr.txt /*utl-changes*
utl-chgAddFootRefs utl_usr.txt /*utl-chgAddFootRefs*
utl-chgCacheGone utl_usr.txt /*utl-chgCacheGone*
utl-chgFragAW utl_usr.txt /*utl-chgFragAW*
utl-chgGuGone utl_usr.txt /*utl-chgGuGone*
utl-chgLineNegative utl_usr.txt /*utl-chgLineNegative*
utl-chgNetworkFile utl_usr.txt /*utl-chgNetworkFile*
utl-chgNewFragConv utl_usr.txt /*utl-chgNewFragConv*
utl-chgNewGenMTHdl utl_usr.txt /*utl-chgNewGenMTHdl*
utl-chgNewHttpAccess utl_usr.txt /*utl-chgNewHttpAccess*
utl-chgNewMailScheme utl_usr.txt /*utl-chgNewMailScheme*
utl-chgNewOperand utl_usr.txt /*utl-chgNewOperand*
utl-chgNewOperators utl_usr.txt /*utl-chgNewOperators*
utl-chgNewVerbose utl_usr.txt /*utl-chgNewVerbose*
utl-chgScmIf utl_usr.txt /*utl-chgScmIf*
utl-chgUI utl_usr.txt /*utl-chgUI*
utl-chgVarNames utl_usr.txt /*utl-chgVarNames*
utl-chgadded utl_usr.txt /*utl-chgadded*
utl-chgchanged utl_usr.txt /*utl-chgchanged*
utl-chghighl utl_usr.txt /*utl-chghighl*
utl-chgincompat utl_usr.txt /*utl-chgincompat*
utl-config utl_usr.txt /*utl-config*
utl-configIntExt utl_usr.txt /*utl-configIntExt*
utl-configcfg utl_usr.txt /*utl-configcfg*
utl-configopt utl_usr.txt /*utl-configopt*
utl-createFiles utl_usr.txt /*utl-createFiles*
utl-credits utl_usr.txt /*utl-credits*
utl-displayHtml utl_usr.txt /*utl-displayHtml*
utl-efmeddep utl_usr.txt /*utl-efmeddep*
utl-fbcallmt utl_usr.txt /*utl-fbcallmt*
utl-fixed utl_usr.txt /*utl-fixed*
utl-fixedBackForth utl_usr.txt /*utl-fixedBackForth*
utl-getStarted utl_usr.txt /*utl-getStarted*
utl-hotKey utl_usr.txt /*utl-hotKey*
utl-infoDir utl_usr.txt /*utl-infoDir*
utl-intro utl_usr.txt /*utl-intro*
utl-knownbugs utl_usr.txt /*utl-knownbugs*
utl-lookupWord utl_usr.txt /*utl-lookupWord*
utl-multiLineURLs utl_usr.txt /*utl-multiLineURLs*
utl-opt_hlighturls utl_usr.txt /*utl-opt_hlighturls*
utl-opt_verbose utl_usr.txt /*utl-opt_verbose*
utl-plugin utl_usr.txt /*utl-plugin*
utl-privateScmHdl utl_usr.txt /*utl-privateScmHdl*
utl-projectManagement utl_usr.txt /*utl-projectManagement*
utl-protvsftype utl_usr.txt /*utl-protvsftype*
utl-smartSamples utl_usr.txt /*utl-smartSamples*
utl-start utl_usr.txt /*utl-start*
utl-startprog utl_usr.txt /*utl-startprog*
utl-tildeSupport utl_usr.txt /*utl-tildeSupport*
utl-tipsdetails utl_usr.txt /*utl-tipsdetails*
utl-todo utl_usr.txt /*utl-todo*
utl-tutCopyFileName utl_usr.txt /*utl-tutCopyFileName*
utl-tutCopyLink utl_usr.txt /*utl-tutCopyLink*
utl-tutOtherCmds utl_usr.txt /*utl-tutOtherCmds*
utl-tutUI utl_usr.txt /*utl-tutUI*
utl-tutVimscript utl_usr.txt /*utl-tutVimscript*
utl-tutVisUrls utl_usr.txt /*utl-tutVisUrls*
utl-tutcreateurls utl_usr.txt /*utl-tutcreateurls*
utl-tutdrivesshares utl_usr.txt /*utl-tutdrivesshares*
utl-tutextfrag utl_usr.txt /*utl-tutextfrag*
utl-tutfolders utl_usr.txt /*utl-tutfolders*
utl-tutfoot utl_usr.txt /*utl-tutfoot*
utl-tutfootfrag utl_usr.txt /*utl-tutfootfrag*
utl-tutfooturl utl_usr.txt /*utl-tutfooturl*
utl-tutforthback utl_usr.txt /*utl-tutforthback*
utl-tutfrags utl_usr.txt /*utl-tutfrags*
utl-tutfragsdref utl_usr.txt /*utl-tutfragsdref*
utl-tutfragsintro utl_usr.txt /*utl-tutfragsintro*
utl-tutfragsline utl_usr.txt /*utl-tutfragsline*
utl-tutfragsnonfile utl_usr.txt /*utl-tutfragsnonfile*
utl-tutfragsrel utl_usr.txt /*utl-tutfragsrel*
utl-tutfragsyn utl_usr.txt /*utl-tutfragsyn*
utl-tutmisc utl_usr.txt /*utl-tutmisc*
utl-tutmtypes utl_usr.txt /*utl-tutmtypes*
utl-tutorial utl_usr.txt /*utl-tutorial*
utl-tutpdffrag utl_usr.txt /*utl-tutpdffrag*
utl-tutrelabs utl_usr.txt /*utl-tutrelabs*
utl-tutscmhttp utl_usr.txt /*utl-tutscmhttp*
utl-tutscmhttpwget utl_usr.txt /*utl-tutscmhttpwget*
utl-tutscmmail utl_usr.txt /*utl-tutscmmail*
utl-tutscmoth utl_usr.txt /*utl-tutscmoth*
utl-tutscmothnonstd utl_usr.txt /*utl-tutscmothnonstd*
utl-tutscmothstd utl_usr.txt /*utl-tutscmothstd*
utl-tuttypeurl utl_usr.txt /*utl-tuttypeurl*
utl-tutverbosemode utl_usr.txt /*utl-tutverbosemode*
utl-tutwordfrag utl_usr.txt /*utl-tutwordfrag*
utl-usagePatterns utl_usr.txt /*utl-usagePatterns*
utl-useOrganizeIdeas utl_usr.txt /*utl-useOrganizeIdeas*
utl-useSourceCode utl_usr.txt /*utl-useSourceCode*
utl-usedesktop utl_usr.txt /*utl-usedesktop*
utl-vimsBackup utl_usr.txt /*utl-vimsBackup*
utl-vimsCompile utl_usr.txt /*utl-vimsCompile*
utl-vimsHeuristicUrl utl_usr.txt /*utl-vimsHeuristicUrl*
utl-writeUrls utl_usr.txt /*utl-writeUrls*
utl_chgcfgscm utl_usr.txt /*utl_chgcfgscm*
utl_usr.txt utl_usr.txt /*utl_usr.txt*

2194
doc/utl_usr.txt Normal file

File diff suppressed because it is too large Load diff

1846
plugin/utl.vim Normal file

File diff suppressed because it is too large Load diff

423
plugin/utl_rc.vim Normal file
View file

@ -0,0 +1,423 @@
" BEGIN OF UTL PLUGIN CONFIGURATION id=utl_rc [
" vim: fdm=marker
let utl__file_rc = expand("<sfile>") " Do not remove this line
" Hints id=hints
"
" - Choose a template variable and uncomment it or create a new one.
" Then issue the command :so % to activate it. You can check whether
" a variable is defined with the command :let utl_cfg_<name>
"
" - You can change the variables in this file whenever you want, not just when
" Utl.vim automatically presented you this file.
"
" - You might want to take any variables defined here into your vimrc file.
" Since vimrc is always loaded before any plugin files you should comment
" all variables to avoid overwriting of your vimrc settings.
" (Deletion of utl_rc.vim is also possible. In this case you should
" preserve the Utl link targets id=xxx plus line :let utl__file_rc
" above (i.e. also take over into you vimrc file).)
" id=schemeHandlers------------------------------------------------------------[
" id=schemeHandlerHttp---------------------------------------------------------[
"
" Allowed conversion specifiers are:
" %u - URL (without fragment, e.g. 'http://www.vim.org/download.php'
" %f - fragment (what comes after the '#', if any)
" %d - display mode (e.g. 'edit', 'tabedit', 'split' etc. Probably only relevant
" if downloaded document handled in Vim)
" [id=utl_cfg_hdl_scm_http]
"
" Hints:
" 1. If g:utl_cfg_hdl_mt_generic is defined then you can probably
" construct utl_cfg_hdl_scm_http by just replacing %u -> %p (Unix) or %u
" -> %P (Windows).
" 2. Instead of directly defining g:utl_cfg_hdl_scm_http it is recommended
" to define g:utl_cfg_hdl_scm_http_system . Doing so enables the dynamic
" handler switching:
" 3. Suggestion for mapping for dynamic switch between handlers [id=map_http]
" :map <Leader>uhs :let g:utl_cfg_hdl_scm_http=g:utl_cfg_hdl_scm_http_system<cr>
" :map <Leader>uhw :let g:utl_cfg_hdl_scm_http=g:utl_cfg_hdl_scm_http__wget<cr>
" [id=utl_cfg_hdl_scm_http_system] {
" Definition of your system's standard web handler, e.g. Firefox.
" Either directly (e.g. Firefox), or indirectly ("start" command
" in Windows).
" Note: Needs not necessarily be the system's standard handler.
" Can be anything but should be seen in contrast to
" utl_cfg_hdl_scm_http__wget below
"
if !exists("g:utl_cfg_hdl_scm_http_system")
if has("win32")
let g:utl_cfg_hdl_scm_http_system = 'silent !cmd /q /c start "dummy title" "%u"'
"let g:utl_cfg_hdl_scm_http_system = 'silent !start C:\Program Files\Internet Explorer\iexplore.exe %u#%f'
"let g:utl_cfg_hdl_scm_http_system = 'silent !start C:\Program Files\Mozilla Firefox\firefox.exe %u#%f'
elseif has("unix")
" TODO: Standard Handler for Unixes that can be shipped
" preconfigured with next utl.vim release
" Probably to distinguish different Unix/Linux flavors.
"
" Proposed for Ubuntu/Debian by Jeremy Cantrell
" to use xdg-open program
" 'silent !xdg-open %u' <- does this work?
"
" 2nd best solution: explicitly configured browser:
"
" Konqueror
"let g:utl_cfg_hdl_scm_http_system = "silent !konqueror '%u#%f' &"
"
" Lynx Browser.
"let g:utl_cfg_hdl_scm_http_system = "!xterm -e lynx '%u#%f'"
"
" Firefox
" Check if an instance is already running, and if yes use it, else start firefox.
" See <URL:http://www.mozilla.org/unix/remote.html> for mozilla/firefox -remote control
"let g:utl_cfg_hdl_scm_http_system = "silent !firefox -remote 'ping()' && firefox -remote 'openURL( %u )' || firefox '%u#%f' &"
endif
" else if MacOS
" ??
"let g:utl_cfg_hdl_scm_http_system = "silent !open -a Safari '%u#%f'"
"
"}
endif
if !exists("g:utl_cfg_hdl_scm_http")
if exists("g:utl_cfg_hdl_scm_http_system")
let g:utl_cfg_hdl_scm_http=g:utl_cfg_hdl_scm_http_system
endif
endif
" [id=utl_cfg_hdl_scm_http__wget]
let g:utl_cfg_hdl_scm_http__wget="call Utl_if_hdl_scm_http__wget('%u')"
" Platform independent
" Delegate to netrw.vim [id=http_netrw]
"let g:utl_cfg_hdl_scm_http="silent %d %u"
"
"]
" id=schemeHandlerScp--------------------------------------------------------------[
" Allowed conversion specifiers are:
" %u - URL (without fragment, e.g. 'scp://www.someServer.de/someFile.txt'
" %f - fragment (what comes after the '#', if any)
" %d - display mode (e.g. 'edit', 'tabedit', 'split' etc. Probably only relevant
" if downloaded document handled in Vim)
" [id=utl_cfg_hdl_scm_scp]
" Delegate to netrw.vim. TODO: Should set utl__hdl_scm_ret_list to buffer name
" NOTE: On Windows I have set g:netrw_scp_cmd="pscp -q" (pscp comes with
" the putty tool), see also <url:vimscript:NetrwSettings>
if !exists("g:utl_cfg_hdl_scm_scp")
let g:utl_cfg_hdl_scm_scp = "silent %d %u"
endif
"]
" id=schemeHandlerMailto-----------------------------------------------------------[
" Allowed conversion specifiers are:
" %u - will be replaced with the mailto URL
"
if !exists("g:utl_cfg_hdl_scm_mailto")
" [id=utl_cfg_hdl_scm_mailto] {
if has("win32")
let g:utl_cfg_hdl_scm_mailto = 'silent !cmd /q /c start "dummy title" "%u"'
endif
" Samples:
" Windows
" Outlook
"let g:utl_cfg_hdl_scm_mailto = 'silent !start C:\Programme\Microsoft Office\Office11\OUTLOOK.EXE /c ipm.note /m %u'
"let g:utl_cfg_hdl_scm_mailto = 'silent !start C:\Program Files\Microsoft Office\Office10\OUTLOOK.exe /c ipm.note /m %u'
"
" Unix
"let g:utl_cfg_hdl_scm_mailto = "!xterm -e mutt '%u'"
"let g:utl_cfg_hdl_scm_mailto = "silent !kmail '%u' &"
"}
endif
" id=schemeHandlerMail---------------------------------------------------------[
" Allowed conversion specifiers are:
" %a - main folder Example:
" %p - folder path Given the URL
" %d - date <url:mail://myfolder/Inbox?date=12.04.2008 15:04&from=foo&subject=bar>
" %f - from the specifiers will be converted as
" %s - subject %a=myfolder, %p=Inbox, %d=12.04.2008 15:04, %f=foo, %s=bar
" Windows
" Outlook [id=utl_cfg_hdl_scm_mail__outlook]
if has("win32")
let g:utl_cfg_hdl_scm_mail__outlook = "call Utl_if_hdl_scm_mail__outlook('%a','%p','%d','%f','%s')"
endif
" [id=utl_cfg_hdl_scm_mail] {
if !exists("g:utl_cfg_hdl_scm_mail")
"let g:utl_cfg_hdl_scm_mail=g:utl_cfg_hdl_scm_mail__outlook
endif
"}
"]
" id=mediaTypeHandlers---------------------------------------------------------[
" Setup of handlers for media types which you don't want to be displayed by Vim.
"
" Allowed conversion specifiers:
"
" %p - Replaced by full path to file or directory
"
" %P - Replaced by full path to file or directory, where the path components
" are separated with backslashes (most Windows programs need this).
" Note that full path might also contain a drive letter.
"
" %f - Replaced by fragment if given in URL, else replaced by empty string.
"
" Details :
" - The variable name is g:utl_cfg_hdl_mt_<media type>, where the characters / . + -
" which can appear in media types are mapped to _ to make a valid variable
" name, e.g. Vim variable for media type 'video/x-msvideo' is
" 'g:utl_cfg_hdl_mt_video_x_msvideo'
" - The "" around the %P is needed to support file names containing blanks
" - Remove the :silent when you are testing with a new string to see what's
" going on (see <URL:vimhelp::silent> for infos on the :silent command).
" Perhaps you like :silent also for production (I don't).
" - NOTE: You can supply any command here, i.e. does not need to be a shell
" command that calls an external program (some cmdline special treatment
" though, see <URL:utl.vim#r=esccmd>)
" - You can introduce new media types to not handle a certain media type
" by Vim (e.g. display it as text in Vim window). Just make sure that the
" new media type is also supported at this place:
" <URL:utl.vim#r=utl_checkmtype>
" - Use the pseudo handler 'VIM' if you like the media type be displayed by
" by Vim. This yields the same result as if the media type is not defined,
" see last item.
" [id=utl_cfg_hdl_mt_generic] {
" You can either define the generic variable or a variable
" for the specific media type, see #r=mediaTypeHandlersSpecific
if !exists("g:utl_cfg_hdl_mt_generic")
if has("win32")
let g:utl_cfg_hdl_mt_generic = 'silent !cmd /q /c start "dummy title" "%P"'
elseif has("unix")
if $WINDOWMANAGER =~? 'kde'
let g:utl_cfg_hdl_mt_generic = 'silent !konqueror "%p" &'
endif
" ? Candidate for Debian/Ubuntu: 'silent !xdg-open %u'
endif
endif
"}
" [id=mediaTypeHandlersSpecific] {
"if !exists("g:utl_cfg_hdl_mt_application_excel")
" let g:utl_cfg_hdl_mt_application_excel = ':silent !start C:\Program Files\Microsoft Office\Office10\EXCEL.EXE "%P"'
"endif
"if !exists("g:utl_cfg_hdl_mt_application_msmsg")
" let g:utl_cfg_hdl_mt_application_msmsg = ':silent !start C:\Program Files\Microsoft Office\Office10\OUTLOOK.EXE -f "%P"'
"endif
"if !exists("g:utl_cfg_hdl_mt_application_powerpoint")
" let g:utl_cfg_hdl_mt_application_powerpoint = ':silent !start C:\Program Files\Microsoft Office\Office10\POWERPNT.EXE "%P"'
"endif
"if !exists("g:utl_cfg_hdl_mt_application_rtf")
" let g:utl_cfg_hdl_mt_application_rtf = ':silent !start C:\Program Files\Windows NT\Accessories\wordpad.exe "%P"'
"endif
"if !exists("g:utl_cfg_hdl_mt_text_html")
" let g:utl_cfg_hdl_mt_text_html = 'VIM'
" Windows
" let g:utl_cfg_hdl_mt_text_html = 'silent !start C:\Program Files\Internet Explorer\iexplore.exe %P'
" KDE
" let g:utl_cfg_hdl_mt_text_html = ':silent !konqueror %p#%f &'
"endif
"if !exists("g:utl_cfg_hdl_mt_application_zip")
" let g:utl_cfg_hdl_mt_application_zip = ':!start C:\winnt\explorer.exe "%P"'
"endif
"if !exists("g:utl_cfg_hdl_mt_video_x_msvideo")
" let g:utl_cfg_hdl_mt_video_x_msvideo = ':silent !start C:\Program Files\VideoLAN\VLC\vlc.exe "%P"'
"endif
"--- Some alternatives for displaying directories [id=utl_cfg_hdl_mt_text_directory] {
if has("win32")
let g:utl_cfg_hdl_mt_text_directory__cmd = ':!start cmd /K cd /D "%P"' " Dos box
endif
let g:utl_cfg_hdl_mt_text_directory__vim = 'VIM' " Vim builtin file explorer
if !exists("g:utl_cfg_hdl_mt_text_directory")
let g:utl_cfg_hdl_mt_text_directory=utl_cfg_hdl_mt_text_directory__vim
"
" KDE
"let g:utl_cfg_hdl_mt_text_directory = ':silent !konqueror %p &'
endif
" Suggestion for mappings for dynamic switch between handlers [id=map_directory]
":map <Leader>udg :let g:utl_cfg_hdl_mt_text_directory=g:utl_cfg_hdl_mt_generic<cr>
":map <Leader>udv :let g:utl_cfg_hdl_mt_text_directory=g:utl_cfg_hdl_mt_text_directory__vim<cr>
":map <Leader>udc :let g:utl_cfg_hdl_mt_text_directory=g:utl_cfg_hdl_mt_text_directory__cmd<cr>
"
"}
" [id=utl_cfg_hdl_mt_application_pdf__acrobat] {
"let g:utl_cfg_hdl_mt_application_pdf__acrobat="call Utl_if_hdl_mt_application_pdf_acrobat('%P', '%f')"
"if !exists("g:utl_cfg_hdl_mt_application_pdf")
" let g:utl_cfg_hdl_mt_application_pdf = g:utl_cfg_hdl_mt_application_pdf__acrobat
"
" Linux/KDE
" let g:utl_cfg_hdl_mt_application_pdf = ':silent !acroread %p &'
"endif
"}
" [id=utl_cfg_hdl_mt_application_msword__word] {
"let g:utl_cfg_hdl_mt_application_msword__word = "call Utl_if_hdl_mt_application_msword__word('%P','%f')"
"if !exists("g:utl_cfg_hdl_mt_application_msword")
" let g:utl_cfg_hdl_mt_application_msword = g:utl_cfg_hdl_mt_application_msword__word
" Linux/Unix
" let g:utl_cfg_hdl_mt_application_msword = ... Open Office
"endif
"}
"if !exists("g:utl_cfg_hdl_mt_application_postscript")
" Seem to need indirect call via xterm, otherwise no way to
" stop at each page
" let g:utl_cfg_hdl_mt_application_postscript = ':!xterm -e gs %p &'
"endif
"if !exists("g:utl_cfg_hdl_mt_audio_mpeg")
" let g:utl_cfg_hdl_mt_audio_mpeg = ':silent !xmms %p &'
"endif
"if !exists("g:utl_cfg_hdl_mt_image_jpeg")
" let g:utl_cfg_hdl_mt_image_jpeg = ':!xnview %p &'
"endif
"}
"]
" Utl interface variables " id=utl_drivers [
" id=utl_if_hdl_scm_http_wget_setup--------------------------------------------[
"
" To make Wget work you need a wget executable in the PATH.
" Windows : Wget not standard. Download for example from
" <url:http://users.ugent.be/~bpuype/wget/#download>
" and put it into to c:\windows\system32
" Unix : Should work under Unix out of the box since wget standard!?
"
" ]
" id=utl_if_hdl_scm_mail__outlook_setup----------------------------------------[
"
" To make Outlook work you for the mail:// schemes you need the VBS OLE
" Automation file:
"
" 1. Adapt the VBS source code to your locale by editing the file utl.vim at
" the position: <url:./utl.vim#r=received> and then :write the file (utl.vim).
"
" 2. Execute the following link to (re-)create the VBS file by cutting it
" out from utl.vim:
"
" <url:vimscript:call Utl_utilCopyExtract(g:utl__file, g:utl__file_if_hdl_scm__outlook, '=== FILE_OUTLOOK_VBS' )>
"
" ]
" id=Utl_if_hdl_mt_application_pdf_acrobat_setup-------------------------------[
"
" To make acrobat work with fragments you need to provide the variable
" g:utl_cfg_hdl_mt_application_pdf_acrobat_exe_path.
"
" Modify and uncomment one of the samples below, then do :so %
" Windows:
" Normally you should get the path by executing in a dos box:
" cmd> ftype acroexch.document
" Here are two samples:
" let g:utl_cfg_hdl_mt_application_pdf_acrobat_exe_path = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"
" let g:utl_cfg_hdl_mt_application_pdf_acrobat_exe_path = 'C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe'
" Full path not needed if Acrobat Reader in path
" Unix:
" Probably Acrobat Reader is in the path, with program's name `acroread'.
" But most certainly the command line options used below will not fit,
" see <url:#r=ar_switches>, and have to be fixed. Please send me proper
" setup for Linux, Solaris etc. I'm also interested in xpdf instead
" of Acrobat Reader (function Utl_if_hdl_mt_application_pdf_xpdf).
" ?? let g:utl_cfg_hdl_mt_application_pdf_acrobat_exe_path = "acroread - ?? "
"
" ]
" id=Utl_if_hdl_mt_application_msword__word_setup------------------------------[
"
" To make MSWord support fragments you need:
"
" 1. Create the VBS OLE Automation file by executing this link:
" <url:vimscript:call Utl_utilCopyExtract(g:utl__file, g:utl__file_if_hdl_mt_application_msword__word, '=== FILE_WORD_VBS' )>
" (This will (re-)create that file by cutting it out from the bottom of this file.)
"
" 2. Provide the variable g:utl_cfg_hdl_mt_application_msword__word_exe_path.
" Modify and uncomment one of the samples below, then do :so %
" Windows:
" Normally you should get the path by executing in a dos box:
" cmd> ftype Word.Document.8
" Here are two samples:
" let g:utl_cfg_hdl_mt_application_msword__word_exe_path = 'C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE'
" let g:utl_cfg_hdl_mt_application_msword__word_exe_path = 'C:\Programme\Microsoft Office\OFFICE11\WINWORD.EXE'
" ]
" ]
" Utl Options id=_utl_options [
"id=utl_opt_verbose------------------------------------------------------------[
" Option utl_opt_verbose switches on tracing. This is useful to figure out
" what's going on, to learn about Utl or to see why things don't work as
" expected.
"
"let utl_opt_verbose=0 " Tracing off (default)
"let utl_opt_verbose=1 " Tracing on
" ]
"id=utl_opt_highlight_urls-----------------------------------------------------[
" Option utl_opt_highlight_urls controls if URLs are highlighted or not.
" Note that only embedded URLs like <url:http://www.vim.org> are highlighted.
"
" Note: Change of the value will only take effect a) after you restart your
" Vim session or b) by :call Utl_setHighl() and subsequent reedit (:e) of the
" current file. Perform the latter by simply executing this URL:
" <url:vimscript:call Utl_setHighl()|:e>
"let utl_opt_highlight_urls='yes' " Highlighting on (default)
"let utl_opt_highlight_urls='no' " Highlighting off
"]
"]
" END OF UTL PLUGIN CONFIGURATION FILE ]

716
plugin/utl_scm.vim Normal file
View file

@ -0,0 +1,716 @@
" ------------------------------------------------------------------------------
" File: plugin/utl_scm.vim -- callbacks implementing the different
" schemes
" Part of the Utl plugin, see ./utl.vim
" Author: Stefan Bittner <stb@bf-consulting.de>
" Licence: This program is free software; you can redistribute it and/or
" modify it under the terms of the GNU General Public License.
" See http://www.gnu.org/copyleft/gpl.txt
" Version: utl 3.0a
" ------------------------------------------------------------------------------
" In this file some scheme specific retrieval functions are defined.
" For each scheme one function named Utl_AddrScheme_xxx() is needed.
"
" - If a scheme (i.e. functions) is missing, the caller Utl_processUrl()
" will notice it and show an appropriate message to the user.
"
" - You can define your own functions:
" How to write a Utl_AddrScheme_xxx function (id=implscmfunc)
" ------------------------------------------
" To implement a specific scheme (e.g. `file', `http') you have to write
" write a handler function named `Utl_AddrScheme_<scheme>' which obeys the
" following rules:
"
" - It takes three arguments:
"
" 1. Arg: Absolute URI
" (See <URL:vimhelp:utl-uri-relabs> to get an absolute URI explained). The
" given `auri' will not have a fragment (without #... at the end).
"
" 2. Arg: Fragment
" Where the value will be '<undef>' if there is no fragment. In most cases a
" handler will not actually deal with the fragment but leaves that job for
" standard fragment processing in Utl by returning a non empty list (see
" next). Examples for fragment processing handlers are
" Utl_AddressScheme_http and Utl_AddressScheme_foot.
"
" 3. Arg: display Mode (dispMode)
" Most handlers will ignore this argument. Exception for instance handlers
" which actually display the retrieved or determined file like
" Utl_AddressScheme_foot. If your function is smart it might, if applicable,
" support the special dispMode values copyFileName (see examples in this file).
"
"
" - It then does what ever it wants.
" But what it normally wants is: retrieve, load, query, address the resource
" identified by `auri'.
" - It Returns a list with 0 (empty list), 1 or 2 elements. [id=scm_ret_list]
" (See vimhelp:List if you don't know what a list is in Vim)
"
" * Empty list means: no subsequent processing by Utl.vim
" Examples where this makes sense:
" ° If the retrieve was not successful, or
" ° if handler already cared for displaying the file (e.g. URL
" delegated to external handler)
"
" * 1st list element = file name (called localPath) provided means:
" a) Utl.vim will delegate localPath to the appropriate file type handler
" or display it the file in Vim-Window.
" It also possible, that the localPath is already displayed in this case
" (Utl.vim will check if the localPath corresponds to a buffer name.)
" Note : It is even possible that localPath does not correspond to
" an existing file or to a file at all. Executing a http URL with
" netrw is an example for this, see: ../plugin/utl_rc.vim#http_netrw.
" Netrw uses the URL as buffer name.
" c) Fragment will be processed (if any).
"
" Details :
" ° File name should be a pathname to (an existing) local file or directory.
" Note : the
" ° File name's path separator should be slash (not backslash).
" ° It does not hurt if file is already displayed (an example for this is
" vimhelp scheme).
"
" * 2nd list element = fragment Mode (fragMode). Allowed values:
" `abs', 'rel'. Defaults to `abs' if no 2nd list element.
" `abs': Fragment will be addressed to beginning of file.
" `rel': Fragment will be addressed relative to current cursor position
" (example: Vimhelp scheme).
"
" Specification of 'scheme handler variable interface' (id=spec_ihsv)
" ----------------------------------------------------
"
" - Variable naming: utl_cfg_hdl_scm_<scheme>
"
" - Variables executed by :exe (see <vimhelp::exe>).
" This implies that the variable has to a valid ex command. (to execute more
" than one line of ex commands a function can be called).
"
" - Should handle the actual link, e.g. download the file.
" But it can do whatever it wants :-)
"
" - Input data: scheme specific conversion specifiers should appear in the
" variable. They will be replaced by Utl.vim when executing an URL, e.g %u
" will be replaced by the actual URL. The available conversion specifiers are
" defined at <url:../plugin/utl_rc.vim#r=utl_cfg_hdl_scm_http> for http etc.
"
" - Output data: an optional global list, which is the same as that of the
" handler itself, see <url:../plugin/utl_scm.vim#r=scm_ret_list>. Since the
" variable's value can be any ex command (and, for instance, not always a
" function) a global variable is used:
" g:utl_hdl_scm_ret_list
" This variable will be initialized to an empty list [] by Utl.vim before
" executing the contents of the variable.
"
" - Exception handling: Normally nothing needs to be done in the variable code.
" Utl.vim checks for v:shell_error and v:errmsg after execution. There are
" situation where setting v:errmsg makes sense. The variable might want to
" issue the error message (Utl.vim does not).
"
if exists("loaded_utl_scm") || &cp || v:version < 700
finish
endif
let loaded_utl_scm = 1
let s:save_cpo = &cpo
set cpo&vim
let g:utl__file_scm = expand("<sfile>")
let s:utl_esccmdspecial = '%#' " keep equal to utl.vim#__esc
"-------------------------------------------------------------------------------
" Addresses/retrieves a local file.
"
" - If `auri' gives a query, then the file is executed (it should be an
" executable program) with the query expression passed as arguments
" arguments. The program's output is written to a (tempname constructed)
" result file.
"
" - else, the local file itself is the result file and is returned.
"
fu! Utl_AddressScheme_file(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_file",1,1)
" authority: can be a
" - windows drive, e.g. `c:'
" - server name - interpret URL as a network share
let authority = UtlUri_authority(a:auri)
let path = ''
if authority =~? '^[a-z]:$'
if has("win32") || has("win16") || has("win64") || has("dos32") || has("dos16")
call Utl_trace("- Am under Windows. Server part denotes a Windows drive: `".authority."'")
let path = authority
endif
elseif authority != '<undef>' && authority != ''
if has("win32") || has("win16") || has("win64") || has("dos32") || has("dos16")
call Utl_trace("- Am under Windows. Server part specified: `".authority."',")
call Utl_trace(" will convert to UNC path //server/sharefolder/path.")
let path = '//' . authority
elseif has("unix")
call Utl_trace("- Am under Unix. Server part specified: `".authority."',")
call Utl_trace(" will convert to server:/path")
" don't know if this really makes sense. See <http://en.wikipedia.org/wiki/Path_%28computing%29>
let path = authority . ':'
endif
endif
let path = path . UtlUri_unescape(UtlUri_path(a:auri))
call Utl_trace("- local path constructed from URL: `".path."'")
" Support of tilde ~ notation.
if stridx(path, "~") != -1
let tildeuser = expand( substitute(path, '\(.*\)\(\~[^/]*\)\(.*\)', '\2', "") )
let path = tildeuser . substitute(path, '\(.*\)\(\~[^/]*\)\(.*\)', '\3', "")
call Utl_trace("- found a ~ (tilde) character in path, expand to $HOME in local path:")
let path = Utl_utilBack2FwdSlashes( path )
call Utl_trace(" ".path."'")
endif
if a:dispMode =~ '^copyFileName'
call Utl_trace("- mode is `copyFileName to clipboard': so quit after filename is known now")
call Utl_trace("- end execution of Utl_AddressScheme_file",1,-1)
return [path]
endif
" If Query defined, then execute the Path (id=filequery)
let query = UtlUri_query(a:auri)
if query != '<undef>' " (N.B. empty query is not undef)
call Utl_trace("- URL contains query expression (".query.") - so try to execute path")
" (Should make functions Query_form(), Query_keywords())
if match(query, '&') != -1 " id=query_form
" (application/x-www-form-urlencoded query to be implemented
" e.g. `?foo=bar&otto=karl')
let v:errmsg = 'form encoded query to be implemented'
echohl ErrorMsg | echo v:errmsg | echohl None
elseif match(query, '+') != -1 " id=query_keywords
let query = substitute(query, '+', ' ', 'g')
endif
let query = UtlUri_unescape(query)
" (Whitespace in keywords should now be escaped before handing off to shell)
let cacheFile = ''
" If redirection char '>' at the end:
" Supply a temp file for redirection and execute the program
" synchronously to wait for its output
if strlen(query)!=0 && stridx(query, '>') == strlen(query)-1
call Utl_trace("- query with > character at end: assume output to a temp file and use it as local path")
let cacheFile = Utl_utilBack2FwdSlashes( tempname() )
let cmd = "!".path." ".query." ".cacheFile
call Utl_trace("- trying to execute command `".cmd."'")
exe cmd
" else start it detached
else
if has("win32") || has("win16") || has("win64") || has("dos32") || has("dos16")
let cmd = "!start ".path." ".query
else
let cmd = "!".path." ".query.'&'
endif
call Utl_trace("- trying to execute command `".cmd."'")
exe cmd
endif
if v:shell_error
let v:errmsg = 'Shell Error from execute searchable Resource'
echohl ErrorMsg | echo v:errmsg | echohl None
if cacheFile != ''
call delete(cacheFile)
endif
call Utl_trace("- end execution of Utl_AddressScheme_file",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_file",1,-1)
if cacheFile == ''
return []
else
return [cacheFile]
endif
endif
call Utl_trace("- end execution of Utl_AddressScheme_file",1,-1)
return [path]
endfu
"-------------------------------------------------------------------------------
"
fu! Utl_AddressScheme_ftp(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_ftp",1,1)
call Utl_trace("- delegating to http scheme handler")
let ret = Utl_AddressScheme_http(a:auri, a:fragment, a:dispMode)
call Utl_trace("- end execution of Utl_AddressScheme_ftp",1,-1)
return ret
endfu
"-------------------------------------------------------------------------------
"
fu! Utl_AddressScheme_https(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_https",1,1)
call Utl_trace("- delegating to http scheme handler")
let ret = Utl_AddressScheme_http(a:auri, a:fragment, a:dispMode)
call Utl_trace("- end execution of Utl_AddressScheme_https",1,-1)
return ret
endfu
"-------------------------------------------------------------------------------
"
fu! Utl_AddressScheme_http(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_http",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName to clipboard' not possible for scheme `http:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_http",1,-1)
return []
endif
if ! exists('g:utl_cfg_hdl_scm_http') " Entering setup
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_http does not exist")
echohl WarningMsg
call input("No scheme handler variable g:utl_cfg_hdl_scm_http defined yet. Entering Setup now. <RETURN>")
echohl None
Utl openLink config:#r=utl_cfg_hdl_scm_http split " (recursion, setup)
call Utl_trace("- end execution of Utl_AddressScheme_http",1,-1)
return []
endif
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_http exists, value=`".g:utl_cfg_hdl_scm_http."'")
let convSpecDict= { 'u': a:auri, 'f': a:fragment, 'd': a:dispMode }
let [errmsg,cmd] = Utl_utilExpandConvSpec(g:utl_cfg_hdl_scm_http, convSpecDict)
if errmsg != ""
echohl ErrorMsg
echo "The content of your Vim variable `".g:utl_cfg_hdl_scm_http."' is invalid and has to be fixed!"
echo "Reason: `".errmsg."'"
echohl None
call Utl_trace("- end execution of Utl_AddressScheme_http",1,-1)
return []
endif
call Utl_trace("- Escape cmdline-special characters (".s:utl_esccmdspecial.") before execution")
" see <URL:vimhelp:cmdline-special>).
let cmd = escape( cmd, s:utl_esccmdspecial)
let g:utl__hdl_scm_ret_list=[]
let v:errmsg = ""
call Utl_trace("- trying to execute command: `".cmd."'")
exe cmd
if v:shell_error || v:errmsg!=""
call Utl_trace("- execution of scm handler returned with v:shell_error or v:errmsg set")
call Utl_trace(" v:shell_error=`".v:shell_error."'")
call Utl_trace(" v:errmsg=`".v:errmsg."'")
call Utl_trace("- end execution of Utl_AddressScheme_http (not successful)",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_http (successful)",1,-1)
return g:utl__hdl_scm_ret_list
endfu
"-------------------------------------------------------------------------------
" Retrieve file via scp.
"
fu! Utl_AddressScheme_scp(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_scp",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `scp:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_scp",1,-1)
return []
endif
if ! exists('g:utl_cfg_hdl_scm_scp') " Entering setup
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_scp does not exist")
echohl WarningMsg
call input("No scheme handler variable g:utl_cfg_hdl_scm_scp defined yet. Entering Setup now. <RETURN>")
echohl None
Utl openLink config:#r=utl_cfg_hdl_scm_scp split " (recursion, setup)
call Utl_trace("- end execution of Utl_AddressScheme_scp",1,-1)
return []
endif
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_scp exists, value=`".g:utl_cfg_hdl_scm_scp."'")
let convSpecDict= { 'u': a:auri, 'f': a:fragment, 'd': a:dispMode }
let [errmsg,cmd] = Utl_utilExpandConvSpec(g:utl_cfg_hdl_scm_scp, convSpecDict)
if errmsg != ""
echohl ErrorMsg
echo "The content of your Vim variable `".g:utl_cfg_hdl_scm_scp."' is invalid and has to be fixed!"
echo "Reason: `".errmsg."'"
echohl None
call Utl_trace("- end execution of Utl_AddressScheme_scp",1,-1)
return []
endif
call Utl_trace("- Escape cmdline-special characters (".s:utl_esccmdspecial.") before execution")
" see <URL:vimhelp:cmdline-special>).
let cmd = escape( cmd, s:utl_esccmdspecial)
let g:utl__hdl_scm_ret_list=[]
let v:errmsg = ""
call Utl_trace("- trying to execute command: `".cmd."'")
exe cmd
if v:shell_error || v:errmsg!=""
call Utl_trace("- execution of scm handler returned with v:shell_error or v:errmsg set")
call Utl_trace("- end execution of Utl_AddressScheme_scp (not successful)",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_scp",1,-1)
return g:utl__hdl_scm_ret_list
endfu
"-------------------------------------------------------------------------------
" The mailto scheme.
" It was mainly implemented to serve as a demo. To show that a resource
" needs not to be a file or document.
"
" Returns empty list. But you could create one perhaps containing
" the return receipt, e.g. 'mail sent succesfully'.
"
fu! Utl_AddressScheme_mailto(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_mailto",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `http:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_http",1,-1)
return []
endif
if ! exists('g:utl_cfg_hdl_scm_mailto') " Entering setup
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_mailto does not exist")
echohl WarningMsg
call input("No scheme handler variable g:utl_cfg_hdl_scm_mailto defined yet. Entering Setup now. <RETURN>")
echohl None
Utl openLink config:#r=utl_cfg_hdl_scm_mailto split " (recursion, setup)
call Utl_trace("- end execution of Utl_AddressScheme_mailto",1,-1)
return []
endif
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_mailto exists, value=`".g:utl_cfg_hdl_scm_mailto."'")
let convSpecDict= { 'u': UtlUri_build_2(a:auri,a:fragment) }
let [errmsg,cmd] = Utl_utilExpandConvSpec(g:utl_cfg_hdl_scm_mailto, convSpecDict)
if errmsg != ""
echohl ErrorMsg
echo "The content of your Vim variable `".g:utl_cfg_hdl_scm_mailto."' is invalid and has to be fixed!"
echo "Reason: `".errmsg."'"
echohl None
call Utl_trace("- end execution of Utl_AddressScheme_mailto",1,-1)
return []
endif
call Utl_trace("- Escape cmdline-special characters (".s:utl_esccmdspecial.") before execution")
let cmd = escape( cmd, s:utl_esccmdspecial)
let g:utl__hdl_scm_ret_list=[]
let v:errmsg = ""
call Utl_trace("- trying to execute command: `".cmd."'")
exe cmd
if v:shell_error || v:errmsg!=""
call Utl_trace("- execution of scm handler returned with v:shell_error or v:errmsg set")
call Utl_trace("- end execution of Utl_AddressScheme_mailto (not successful)",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_mailto",1,-1)
return g:utl__hdl_scm_ret_list
endfu
"-------------------------------------------------------------------------------
" Scheme for accessing Unix Man Pages.
" Useful for commenting program sources.
"
" Example: /* "See <URL:man:fopen#r+> for the r+ argument" */
"
" Possible enhancement: Support sections, i.e. <URL:man:fopen(3)#r+>
"
fu! Utl_AddressScheme_man(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_man",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `man:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_man",1,-1)
return []
endif
exe "Man " . UtlUri_unescape( UtlUri_opaque(a:auri) )
if v:errmsg =~ '^Sorry, no man entry for'
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_man",1,-1)
return [Utl_utilBack2FwdSlashes( expand("%:p") ), 'rel']
endfu
"-------------------------------------------------------------------------------
" Scheme for footnotes. Normally by heuristic URL like [1], which is
" transformed into foot:1 before calling this handler. Given
" foot:1 as reference, a referent is searched beginning from
" the end of the current file. The referent can look like:
" [1] or
" [1]:
" where only whitespace can appear in front in the same line. If the reference
" has a fragment, e.g. [1]#string or even an empty fragment, e.g. [1]#
" the value of the footnote is tried to derefence, i.e. automatic forwarding.
"
fu! Utl_AddressScheme_foot(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_foot",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `foot:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_foot",1,-1)
return []
endif
let opaque = UtlUri_unescape( UtlUri_opaque(a:auri) )
let reftPat = '\c\m^\s*\(\['.opaque.'\]:\?\)'
call Utl_trace("- searching for referent pattern `".reftPat."' bottom up until current line...",0)
let refcLine = line('.') | let refcCol = col('.')
call cursor( line('$'), col('$') )
let reftLine = search(reftPat, 'Wb', refcLine+1)
if reftLine==0
call Utl_trace("not found")
endif
if reftLine==0
call Utl_trace("- now searching for referent pattern `".reftPat."' top down until current line...",0)
call cursor(1, 1)
" (avoid stopline==0, this is special somehow. With -1 instead,
" stopping works in the case of reference in line 1)
let reftLine = search(reftPat, 'Wc', refcLine==1 ? -1 : refcLine-1 )
if reftLine==0
call Utl_trace("not found. Giving up")
call cursor(refcLine, refcCol)
endif
endif
if reftLine==0
let v:errmsg = "Reference has not target in current buffer. Provide another line starting with `[".opaque."]' or `".opaque.".' !"
echohl ErrorMsg | echo v:errmsg | echohl None
return []
endif
call Utl_trace("found, in line `".reftLine."'")
" Feature automatic forwarding
if a:fragment != '<undef>'
call Utl_trace("- fragment is defined, so try dereferencing foonote's content")
call Utl_trace(" by trying to position one character past referent")
" This should exactly fail in case there is no one additional non white character
let l=search(reftPat.'.', 'ce', reftLine)
if l == 0
let v:errmsg = "Cannot dereference footnote: Empty footnote"
echohl ErrorMsg | echo v:errmsg | echohl None
return []
elseif l != reftLine
let v:errmsg = "Cannot dereference footnote: Internal Error: line number mismatch"
echohl ErrorMsg | echo v:errmsg | echohl None
return []
endif
call Utl_trace("- fine, footnote not empty and cursor positioned to start of its")
call Utl_trace(" content (column ".col('.').") and try to get URL from under the cursor")
let uriRef = Utl_getUrlUnderCursor()
if uriRef == ''
let v:errmsg = "Cannot not dereference footnote: No URL under cursor"
echohl ErrorMsg | echo v:errmsg | echohl None
return []
endif
call Utl_trace("- combine URL / URL-reference under cursor with fragment of [] reference")
let uri = UriRef_getUri(uriRef)
let fragmentOfReferent = UriRef_getFragment(uriRef)
if fragmentOfReferent != '<undef>'
call Utl_trace("- discard non empty fragment `".fragmentOfReferent."' of referent")
endif
call Utl('openLink', UtlUri_build_2(uri, a:fragment), a:dispMode)
endif
call Utl_trace("- end execution of Utl_AddressScheme_foot",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_foot",1,-1)
return [Utl_utilBack2FwdSlashes( expand("%:p") )]
endfu
"-------------------------------------------------------------------------------
" A scheme for quickly going to the setup file utl_rc.vim, e.g.
" :Gu config:
"
fu! Utl_AddressScheme_config(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_config",1,1)
let path = g:utl__file_rc
call Utl_trace("- set local path to equal utl variable g:utl__file_scm: `".path."'")
call Utl_trace("- end execution of Utl_AddressScheme_config",1,-1)
return [ Utl_utilBack2FwdSlashes(path) ]
endfu
"id=vimscript-------------------------------------------------------------------
" A non standard scheme for executing vim commands
" <URL:vimscript:set ts=4>
"
fu! Utl_AddressScheme_vimscript(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_vimscript",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `vimscript:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_vimscript",1,-1)
return []
endif
let exCmd = UtlUri_unescape( UtlUri_opaque(a:auri) )
call Utl_trace("- executing Vim Ex-command: `:".exCmd."'\n") " CR054_extra_nl
"echo " DBG utl_opt_verbose=`".g:utl_opt_verbose."'"
exe exCmd
"echo " DBG (after) utl_opt_verbose=`".g:utl_opt_verbose."'"
call Utl_trace("- end execution of Utl_AddressScheme_vimscript (successful)",1,-1)
return []
endfu
fu! Utl_AddressScheme_vimtip(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_vimtip",1,1)
let url = "http://vim.sf.net/tips/tip.php?tip_id=". UtlUri_unescape( UtlUri_opaque(a:auri) )
call Utl_trace("- delegating to http scheme handler with URL `".url."'")
let ret = Utl_AddressScheme_http(url, a:fragment, a:dispMode)
call Utl_trace("- end execution of Utl_AddressScheme_vimtip",1,-1)
return ret
endfu
"-------------------------------------------------------------------------------
" A non standard scheme for getting Vim help
"
fu! Utl_AddressScheme_vimhelp(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_vimhelp",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `vimhelp:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_vimhelp",1,-1)
return []
endif
let exCmd = "help ".UtlUri_unescape( UtlUri_opaque(a:auri) )
call Utl_trace("- executing Vim Ex-command: `:".exCmd."'\n") " CR054_extra_nl
exe exCmd
if v:errmsg =~ '^Sorry, no help for'
call Utl_trace("- end execution of Utl_AddressScheme_vimhelp",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_vimhelp (successful)",1,-1)
return [ Utl_utilBack2FwdSlashes( expand("%:p") ), 'rel' ]
endfu
"-------------------------------------------------------------------------------
" The mail-scheme.
" This is not an official scheme in the internet. I invented it to directly
" access individual Mails from a mail client.
"
" Synopsis :
" mail://<box-path>?query
"
" where query = [date=]<date>[&from=<from>][&subject=<subject>]
"
" Examples :
" <url:mail:///Inbox?24.07.2007 13:23>
" <url:mail://archive/Inbox?24.07.2007 13:23>
"
fu! Utl_AddressScheme_mail(auri, fragment, dispMode)
call Utl_trace("- start execution of Utl_AddressScheme_mail",1,1)
if a:dispMode =~ '^copyFileName'
echohl ErrorMsg | echo "function `copyFileName name to clipboard' not possible for scheme `mail:'" | echohl None
call Utl_trace("- end execution of Utl_AddressScheme_mail",1,-1)
return []
endif
if ! exists('g:utl_cfg_hdl_scm_mail') " Entering setup
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_mail does not exist")
echohl WarningMsg
call input("No scheme handler variable g:utl_cfg_hdl_scm_mail defined yet. Entering Setup now. <RETURN>")
echohl None
Utl openLink config:#r=utl_cfg_hdl_scm_mail split
call Utl_trace("- end execution of Utl_AddressScheme_mail",1,-1)
return []
endif
call Utl_trace("- Vim variable g:utl_cfg_hdl_scm_mail exists, value=`".g:utl_cfg_hdl_scm_mail."'")
let authority = UtlUri_unescape( UtlUri_authority(a:auri) )
let path = UtlUri_unescape( UtlUri_path(a:auri) )
let query = UtlUri_unescape( UtlUri_query(a:auri) )
call Utl_trace("- URL path components: authority=`".authority."', path=`".path."'" )
" Parse query expression
if query == '<undef>' || query == ""
let v:errmsg = 'Query expression missing'
echohl ErrorMsg | echo v:errmsg | echohl None
return []
endif
let q_from = ''
let q_subject = ''
let q_date = ''
while 1
let pos = stridx(query, '&')
if pos == -1
let entry = query
else
let entry = strpart(query, 0, pos)
let query = strpart(query, pos+1)
endif
if entry =~ '^from='
let q_from = substitute(entry, '.*=', '', '')
elseif entry =~ '^subject='
let q_subject = substitute(entry, '.*=', '', '')
elseif entry =~ '^date='
let q_date = substitute(entry, '.*=', '', '')
else
let q_date = entry
endif
if pos == -1
break
endif
endwhile
call Utl_trace("- URL query attributes: date=`".q_date."', subject=`".q_subject."', from=`".q_from."'" )
let convSpecDict= { 'a': authority, 'p': path, 'd': q_date, 'f': q_from, 's': q_subject }
let [errmsg,cmd] = Utl_utilExpandConvSpec(g:utl_cfg_hdl_scm_mail, convSpecDict)
if errmsg != ""
echohl ErrorMsg
echo "The content of your Vim variable g:utl_cfg_hdl_scm_mail=".g:utl_cfg_hdl_scm_mail."' is invalid and has to be fixed!"
echo "Reason: `".errmsg."'"
echohl None
call Utl_trace("- end execution of Utl_AddressScheme_mail (not successful)",1,-1)
return []
endif
call Utl_trace("- Escape cmdline-special characters (".s:utl_esccmdspecial.") before execution")
let cmd = escape( cmd, s:utl_esccmdspecial)
let g:utl__hdl_scm_ret_list=[]
let v:errmsg = ""
call Utl_trace("- trying to execute command `".cmd."'")
exe cmd
if v:shell_error || v:errmsg!=""
call Utl_trace("- execution of scm handler returned with v:shell_error or v:errmsg set")
call Utl_trace("- end execution of Utl_AddressScheme_mail (not successful)",1,-1)
return []
endif
call Utl_trace("- end execution of Utl_AddressScheme_mail (successful)",1,-1)
return g:utl__hdl_scm_ret_list
endfu
let &cpo = s:save_cpo

292
plugin/utl_uri.vim Normal file
View file

@ -0,0 +1,292 @@
" ------------------------------------------------------------------------------
" File: plugin/utl_uri.vim -- module for parsing URIs
" Part of the Utl plugin, see ./utl.vim
" Author: Stefan Bittner <stb@bf-consulting.de>
" Licence: This program is free software; you can redistribute it and/or
" modify it under the terms of the GNU General Public License.
" See http://www.gnu.org/copyleft/gpl.txt
" Version: utl 3.0a
" ------------------------------------------------------------------------------
" Parses URI-References.
" (Can be used independantly from Utl.)
" (An URI-Reference is an URI + fragment: myUri#myFragment.
" See also <URL:vimhelp:utl-uri-refs>.
" Aims to be compliant with <URL:http://www.ietf.org/rfc/rfc2396.txt>
"
" NOTE: The distinction between URI and URI-Reference won't be hold out
" (is that correct english? %-\ ). It should be clear from the context.
" The fragment goes sometimes with the URI, sometimes not.
"
" Usage:
"
" " Parse an URI
" let uri = 'http://www.google.com/search?q=vim#tn=ubiquitous'
"
" let scheme = UtlUri_scheme(uri)
" let authority = UtlUri_authority(uri)
" let path = UtlUri_path(uri)
" let query = UtlUri_query(uri)
" let fragment = UtlUri_fragment(uri)
"
" " Rebuild the URI
" let uriRebuilt = UtlUri_build(scheme, authority, path, query, fragment)
"
" " UtlUri_build a new URI
" let uriNew = UtlUri_build('file', 'localhost', 'path/to/file', '<undef>', 'myFrag')
"
" " Recombine an uri-without-fragment with fragment to an uri
" let uriRebuilt = UtlUri_build_2(absUriRef, fragment)
"
" let unesc = UtlUri_unescape('a%20b%3f') " -> unesc==`a b?'
"
" Details:
" Authority, query and fragment can have the <undef> value (literally!)
" (similar to undef-value in Perl). That's distinguished from
" _empty_ values! Example: http:/// yields UtlUri_authority=='' where as
" http:/path/to/file yields UtlUri_authority=='<undef>'.
" See also
" <URL:http://www.ietf.org/rfc/rfc2396.txt#Note that we must be careful>
"
" Internal Note:
" Ist not very performant in typical usage (but clear).
" s:UtlUri_parse executed n times for getting n components of same uri
if exists("loaded_utl_uri") || &cp || v:version < 700
finish
endif
let loaded_utl_uri = 1
let s:save_cpo = &cpo
set cpo&vim
let g:utl__file_uri = expand("<sfile>")
"------------------------------------------------------------------------------
" Parses `uri'. Used by ``public'' functions like UtlUri_path().
" - idx selects the component (see below)
fu! s:UtlUri_parse(uri, idx)
" See <URL:http://www.ietf.org/rfc/rfc2396.txt#^B. Parsing a URI Reference>
"
" ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
" 12 3 4 5 6 7 8 9
"
" scheme = \2
" authority = \4
" path = \5
" query = \7
" fragment = \9
" (don't touch! ;-) id=_regexparse
return substitute(a:uri, '^\(\([^:/?#]\+\):\)\=\(//\([^/?#]*\)\)\=\([^?#]*\)\(?\([^#]*\)\)\=\(#\(.*\)\)\=', '\'.a:idx, '')
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_scheme(uri)
let scheme = s:UtlUri_parse(a:uri, 2)
" empty scheme impossible (an uri like `://a/b' is interpreted as path = `://a/b').
if( scheme == '' )
return '<undef>'
endif
" make lowercase, see
" <URL:http://www.ietf.org/rfc/rfc2396.txt#resiliency>
return tolower( scheme )
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_opaque(uri)
return s:UtlUri_parse(a:uri, 3) . s:UtlUri_parse(a:uri, 5) . s:UtlUri_parse(a:uri, 6)
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_authority(uri)
if s:UtlUri_parse(a:uri, 3) == s:UtlUri_parse(a:uri, 4)
return '<undef>'
else
return s:UtlUri_parse(a:uri, 4)
endif
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_path(uri)
return s:UtlUri_parse(a:uri, 5)
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_query(uri)
if s:UtlUri_parse(a:uri, 6) == s:UtlUri_parse(a:uri, 7)
return '<undef>'
else
return s:UtlUri_parse(a:uri, 7)
endif
endfu
"-------------------------------------------------------------------------------
fu! UtlUri_fragment(uri)
if s:UtlUri_parse(a:uri, 8) == s:UtlUri_parse(a:uri, 9)
return '<undef>'
else
return s:UtlUri_parse(a:uri, 9)
endif
endfu
"------------------------------------------------------------------------------
" Concatenate uri components into an uri -- opposite of s:UtlUri_parse
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#are recombined>
"
" - it should hold: s:UtlUri_parse + UtlUri_build = exactly the original Uri
"
fu! UtlUri_build(scheme, authority, path, query, fragment)
let result = ""
if a:scheme != '<undef>'
let result = result . a:scheme . ':'
endif
if a:authority != '<undef>'
let result = result . '//' . a:authority
endif
let result = result . a:path
if a:query != '<undef>'
let result = result . '?' . a:query
endif
if a:fragment != '<undef>'
let result = result . '#' . a:fragment
endif
return result
endfu
"------------------------------------------------------------------------------
" Build uri from uri without fragment and fragment
"
fu! UtlUri_build_2(absUriRef, fragment)
let result = ""
if a:absUriRef != '<undef>'
let result = result . a:absUriRef
endif
if a:fragment != '<undef>'
let result = result . '#' . a:fragment
endif
return result
endfu
"------------------------------------------------------------------------------
" Constructs an absolute URI from a relative URI `uri' by the help of given
" `base' uri and returns it.
"
" See
" <URL:http://www.ietf.org/rfc/rfc2396.txt#^5.2. Resolving Relative References>
" - `uri' may already be absolute (i.e. has scheme), is then returned
" unchanged
" - `base' should really be absolute! Otherwise the returned Uri will not be
" absolute (scheme <undef>). Furthermore `base' should be reasonable (e.g.
" have an absolute Path in the case of hierarchical Uri)
"
fu! UtlUri_abs(uri, base)
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#If the scheme component>
if UtlUri_scheme(a:uri) != '<undef>'
return a:uri
endif
let scheme = UtlUri_scheme(a:base)
" query, fragment never inherited from base, wether defined or not,
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#not inherited from the base URI>
let query = UtlUri_query(a:uri)
let fragment = UtlUri_fragment(a:uri)
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#If the authority component is defined>
let authority = UtlUri_authority(a:uri)
if authority != '<undef>'
return UtlUri_build(scheme, authority, UtlUri_path(a:uri), query, fragment)
endif
let authority = UtlUri_authority(a:base)
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#If the path component begins>
let path = UtlUri_path(a:uri)
if path[0] == '/'
return UtlUri_build(scheme, authority, path, query, fragment)
endif
" see <URL:http://www.ietf.org/rfc/rfc2396.txt#needs to be merged>
" step a)
let new_path = substitute( UtlUri_path(a:base), '[^/]*$', '', '')
" step b)
let new_path = new_path . path
" TODO: implement the missing steps (purge a/b/../c/ into a/c/ etc),
" CR048#r=_diffbuffs: Implement one special case though: Remove ./ segments
" since these can trigger a Vim-Bug where two path which specify the same
" file lead to different buffers, which in turn is a problem for Utl.
" Have to substitute twice since adjacent ./ segments, e.g. a/././b
" not substituted else (despite 'g' flag). Another Vim-Bug?
let new_path = substitute( new_path, '/\./', '/', 'g')
let new_path = substitute( new_path, '/\./', '/', 'g')
return UtlUri_build(scheme, authority, new_path, query, fragment)
endfu
"------------------------------------------------------------------------------
" strip eventual #myfrag.
" return uri. can be empty
"
fu! UriRef_getUri(uriref)
let idx = match(a:uriref, '#')
if idx==-1
return a:uriref
endif
return strpart(a:uriref, 0, idx)
endfu
"------------------------------------------------------------------------------
" strip eventual #myfrag.
" return uri. can be empty or <undef>
"
fu! UriRef_getFragment(uriref)
let idx = match(a:uriref, '#')
if idx==-1
return '<undef>'
endif
return strpart(a:uriref, idx+1, 9999)
endfu
"------------------------------------------------------------------------------
" Unescape unsafe characters in given string,
" e.g. transform `10%25%20is%20enough' to `10% is enough'.
"
" - typically string is an uri component (path or fragment)
"
" (see <URL:http://www.ietf.org/rfc/rfc2396.txt#2. URI Characters and Escape Sequences>)
"
fu! UtlUri_unescape(esc)
" perl: $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg
let esc = a:esc
let unesc = ''
while 1
let ibeg = match(esc, '%[0-9A-Fa-f]\{2}')
if ibeg == -1
return unesc . esc
endif
let chr = nr2char( "0x". esc[ibeg+1] . esc[ibeg+2] )
let unesc = unesc . strpart(esc, 0, ibeg) . chr
let esc = strpart(esc, ibeg+3, 9999)
endwhile
endfu
let &cpo = s:save_cpo