├── .version ├── COPYING ├── README.md ├── bin ├── lorikeem └── mktags ├── doc ├── KBAWDUMP.1 ├── lorikeem.1 └── mktags.1 ├── install.sh └── src ├── lorikeem ├── lorikeem-dotemacs.el ├── lorikeem-path.sh └── lorikeem.el ├── mumps ├── KBAWDUMP.m ├── KBBMDBUG.m └── KBBMLRKM.m └── yasnippet ├── .travis.yml ├── CONTRIBUTING.md ├── NEWS ├── README.mdown ├── Rakefile ├── doc ├── .nosearch ├── faq.org ├── images │ ├── bg-content-left.png │ ├── bg-content-right.png │ ├── bg-content.png │ ├── bg-navigation-item-hover.png │ ├── bg-navigation-item.png │ ├── bg-navigation.png │ ├── body.png │ ├── customization-group.png │ ├── dropdown-menu.png │ ├── external.png │ ├── ido-menu.png │ ├── menu-1.png │ ├── menu-2.png │ ├── menu-groups.png │ ├── menu-parent.png │ ├── minor-mode-indicator.png │ └── x-menu.png ├── index.org ├── nav-menu.html.inc ├── org-setup.inc ├── snippet-development.org ├── snippet-expansion.org ├── snippet-menu.org ├── snippet-organization.org ├── snippet-reference.org ├── stylesheets │ ├── manual.css │ └── styles.css └── yas-doc-helper.el ├── snippets └── mumps-mode │ ├── A │ ├── ASCII │ ├── BLD^DIALOG │ ├── C │ ├── CHAR │ ├── CHK^DIE │ ├── CLEAN^DILF │ ├── CREF^DILF │ ├── CREIXN^DDMOD │ ├── D │ ├── DATA │ ├── DA^DILF │ ├── DELIXN^DDMOD │ ├── DELIX^DDMOD │ ├── DT^DILF │ ├── E │ ├── EXTERNAL^DILFD │ ├── EXTRACT │ ├── EZBLD^DIALOG │ ├── F │ ├── FDA^DILF │ ├── FIELDLST^DID │ ├── FIELD^DID │ ├── FILELST^DID │ ├── FILESEC^DDMOD │ ├── FILE^DID │ ├── FILE^DIE │ ├── FIND │ ├── FIND1^DIC │ ├── FIND^DIC │ ├── FLDNUM^DILFD │ ├── FN │ ├── FNUMBER │ ├── G │ ├── GET │ ├── GET1^DID │ ├── GET1^DIQ │ ├── GETS^DIQ │ ├── HELP^DIE │ ├── HTML^DILF │ ├── IENS^DILF │ ├── J │ ├── JUSTIFY │ ├── KEYVAL^DIE │ ├── L │ ├── LENGTH │ ├── LIST^DIC │ ├── MSG^DIALOG │ ├── NA │ ├── NAME │ ├── O │ ├── ORDER │ ├── OREF^DILF │ ├── P │ ├── PIECE │ ├── PRD^DILFD │ ├── Q │ ├── QL │ ├── QLENGTH │ ├── QS │ ├── QSUBSCRIPT │ ├── QUERY │ ├── R │ ├── RANDOM │ ├── RECALL^DILFD │ ├── REVERSE │ ├── ROOT^DILFD │ ├── S │ ├── SACHEADER │ ├── SELECT │ ├── ST │ ├── STACK │ ├── T │ ├── TEXT │ ├── TR │ ├── TRANSLATE │ ├── UPDATE^DIE │ ├── VALS^DIE │ ├── VALUE1^DILF │ ├── VALUES^DILF │ ├── VAL^DIE │ ├── VFIELD^DILFD │ ├── VFILE^DILFD │ └── WP^DIE ├── yasnippet-debug.el ├── yasnippet-tests.el └── yasnippet.el /.version: -------------------------------------------------------------------------------- 1 | 0.99.4 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LorikeeM 2 | ======== 3 | 4 | LorikeeM MUMPS Developer Tools for Emacs 5 | 6 | This major mode for emacs provides basic syntax highlighting for MUMPS. 7 | It supports most features of YottaDB and Fidelity GT.M. 8 | 9 | ### License 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU Affero General Public License (AGPL) 13 | as published by the Free Software Foundation, either version 3 of 14 | the License, or (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Affero General Public License for more details. 20 | 21 | You should have received a copy of the GNU Affero General Public License 22 | along with this program. If not, see http://www.gnu.org/licenses/. 23 | 24 | ### Installation 25 | 26 | 1) Download LorikeeM from [coherent-logic.com](http://www.coherent-logic.com/cm/products/lorikeem) 27 | 28 | 2) Extract the downloaded tar.gz file. This will create a *lorikeem* 29 | subdirectory. 30 | 31 | 3) Change to the *lorikeem* subdirectory 32 | 33 | 4) Run *./install.sh* 34 | 35 | 5) Follow the prompts 36 | 37 | ### Credits 38 | 39 | KBAWDUMP.m and mktags were written by DL Wicksell for his excellent 40 | Axiom tools for the vim editor. https://github.com/dlwicksell/axiom 41 | -------------------------------------------------------------------------------- /bin/lorikeem: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LORIKEEM_VERSION="0.99.3" 4 | echo " " 5 | echo " " 6 | echo " " 7 | echo " _ _ _ __ __ " 8 | echo "| | ___ _ __(_) | _____ ___| \/ |" 9 | echo "| | / _ \| '__| | |/ / _ \/ _ \ |\/| |" 10 | echo "| |__| (_) | | | | < __/ __/ | | |" 11 | echo "|_____\___/|_| |_|_|\_\___|\___|_| |_|" 12 | echo " " 13 | echo " LorikeeM MUMPS Developer Tools " 14 | echo " Version ${LORIKEEM_VERSION} " 15 | echo " " 16 | echo " Copyright (C) 2013 " 17 | echo " Coherent Logic Development LLC " 18 | echo " " 19 | echo " " 20 | echo " " 21 | emacs -T "LorikeeM MUMPS Developer Tools" -rv -mm -l "/opt/lorikeem/lorikeem.el" -f mumps-mode $1 -------------------------------------------------------------------------------- /bin/mktags: -------------------------------------------------------------------------------- 1 | #! /bin/bash - 2 | # 3 | # Package: Axiom 4 | # File: mktags 5 | # Summary: Builds a tag file for MUMPS/GT.M routines 6 | # Maintainer: David Wicksell 7 | # Last Modified: Dec 16, 2012 8 | # 9 | # Written by David Wicksell 10 | # Copyright © 2010-2012 Fourth Watch Software, LC 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU Affero General Public License (AGPL) 14 | # as published by the Free Software Foundation, either version 3 of 15 | # the License, or (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU Affero General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Affero General Public License 23 | # along with this program. If not, see http://www.gnu.org/licenses/. 24 | # 25 | # This script was created to be run in a Red Hat or Ubuntu environment. 26 | # 27 | # This program creates a file called mtags which it 28 | # will place in the directory in which you called it; 29 | # or .mtags, which it will place in the home directory. 30 | # When you use Vim or Emacs, it will allow you to jump 31 | # to the entryref under the cursor and back to the MUMPS 32 | # code which calls it. 33 | # 34 | # Call it either with the -g option, which searchs 35 | # through the $gtmroutines environment variable, and 36 | # will build the tags file recursively; or with the 37 | # -d option and a directory name, which will also build 38 | # the tags file recursively. You may optionally call it 39 | # with a list of routines, either with the -d option or 40 | # not, and it will build a different tags file than the 41 | # -g option. You should therefore add mtags and ~/.mtags 42 | # to your Vim configuration. 43 | # 44 | # E.g. set tags+=mtags,~/.mtags 45 | # 46 | # If you installed Axiom via the install script 47 | # provided in the tarball, it will set the tags option 48 | # for you. 49 | # 50 | # If you also include the -e option, it will build the 51 | # tags file in Emacs mode, and also call it either 52 | # MTAGS which it will place in the directory in which 53 | # you called it, or .MTAGS which it will place in the 54 | # home directory. This will allow you to run mktags 55 | # twice and create a tags file for both Vim and Emacs. 56 | 57 | 58 | # Usage message 59 | function Usage 60 | { 61 | cat << EOF 62 | Usage: ${SCRIPT} [-elqv] [-d dir | file]+ 63 | or ${SCRIPT} [-elqv] -g 64 | or ${SCRIPT} -h 65 | EOF 66 | } # End of Usage 67 | 68 | # Log messages to the system log and/or stdout and stderr 69 | function Log 70 | { 71 | if [ "${LOG}" == "on" ] 72 | then 73 | if [ "$1" == "err" ] 74 | then 75 | if [ "${VERBOSE}" == "off" ] 76 | then 77 | if [ "${QUIET}" == "on" ] 78 | then 79 | logger -i -p user.$1 -t mktags "$2" 2>> ${LOGFILE} 80 | else 81 | logger -is -p user.$1 -t mktags "$2" 2>&1 82 | fi 83 | else 84 | if [ "${QUIET}" == "off" ] 85 | then 86 | echo "$2" 87 | fi 88 | fi 89 | fi 90 | 91 | echo "$2" >> ${LOGFILE} 92 | else 93 | if [ "$1" == "err" ] 94 | then 95 | if [ "${QUIET}" == "off" ] 96 | then 97 | echo "$2" 98 | fi 99 | fi 100 | fi 101 | } # End of Log 102 | 103 | # Error message and exit status 104 | function Error 105 | { 106 | local RET 107 | 108 | case "$1" in 109 | ctags) 110 | Log err "Install ctags in order to continue" 111 | 112 | RET=1 113 | ;; 114 | version) 115 | Log err "Install exuberant-ctags in order to continue" 116 | 117 | RET=2 118 | ;; 119 | env) 120 | Log err "-$2 requires you to set the \$gtmroutines environment variable" 121 | 122 | RET=3 123 | ;; 124 | option) 125 | Log err "-$2 is not a valid option" 126 | 127 | if [ "${QUIET}" == "off" ] 128 | then 129 | Usage 130 | fi 131 | 132 | RET=4 133 | ;; 134 | args) 135 | Log err "Supply either -g, -d , or a list of MUMPS routines" 136 | 137 | if [ "${QUIET}" == "off" ] 138 | then 139 | Usage 140 | fi 141 | 142 | RET=5 143 | ;; 144 | running) 145 | Log err "${SCRIPT} is already running" 146 | 147 | RET=6 148 | ;; 149 | '*') 150 | #Should never get here 151 | Log err "Bad error code ($1) in ${SCRIPT}" 152 | 153 | RET=7 154 | esac 155 | 156 | if [ "${LOG}" == "on" ] 157 | then 158 | Log notice "Finished ${SCRIPT} ; User: ${USER} ; `date`" 159 | Log notice "-----------------------------------------------------------" 160 | fi 161 | 162 | exit ${RET} 163 | } # End of Error 164 | 165 | # Build the tags file 166 | function Mtags 167 | { 168 | local DIRS="$@" 169 | 170 | #Unmap every language already defined with a .m extension 171 | local LANGMAP=`ctags --list-maps | grep "\.m \|\.m$" | awk '{print $1}'` 172 | LANGMAP=`echo ${LANGMAP} | sed "s/ /:,/"` 173 | 174 | #only add the last :, if there are languages to unmap 175 | if [ ${LANGMAP} ] 176 | then 177 | LANGMAP=`echo ${LANGMAP}`:, 178 | fi 179 | 180 | local BUFFER=`ctags ${ARGS} -a --fields=+n --langdef=MUMPS \ 181 | --langmap=${LANGMAP}MUMPS:.m --languages=-all,+MUMPS \ 182 | --regex-MUMPS="/^([%[:alnum:]]+)/\1\^/l,label,line label entryref/i" \ 183 | ${DIRS} 2>&1` 184 | 185 | if [ "${BUFFER}" ] 186 | then 187 | Log err "${BUFFER}" 188 | fi 189 | } # End of Mtags 190 | 191 | # Build a tags file by parsing the $gtmroutines search path 192 | function Mtags_gtm 193 | { 194 | local DIR DIRS 195 | 196 | for DIR in ${gtmroutines} 197 | do 198 | #regex syntax (=~) for the following test does not work in Red Hat Bash 199 | if [[ ${DIR} != ${DIR/"("/} ]] #$gtmroutines with "()" source syntax 200 | then 201 | DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1` 202 | elif [[ ${DIR} != ${DIR/")"/} ]] #$gtmroutines with "()" source syntax 203 | then 204 | DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1` 205 | elif [ "${DIR: -3}" == ".so" ] 206 | then 207 | DIR=`dirname ${DIR}` 208 | elif ! ls ${DIR}/*.m &> /dev/null 209 | then 210 | DIR=`dirname ${DIR}` 211 | fi 212 | 213 | DIRS="${DIRS} ${DIR}" 214 | done 215 | 216 | Mtags ${DIRS} 217 | } # End of Mtags_gtm 218 | 219 | 220 | #mktags script starts here 221 | SCRIPT=`basename $0` 222 | TAGDIR=${HOME}/.mktags.lock 223 | 224 | #define $USER within a limited environment. 225 | #E.g. when being run by cron 226 | if [ -z "${USER}" ] 227 | then 228 | USER=${LOGNAME} 229 | fi 230 | 231 | #define defaults which will be switched by command line options 232 | DIRECTORY=off EMACS=off 233 | GTM=off LOG=off 234 | QUIET=off VERBOSE=off 235 | 236 | while getopts :d:eghlqv OPT 237 | do 238 | case ${OPT} in 239 | d) #directory mode 240 | if [ "${GTM}" == "off" ] 241 | then 242 | DIRECTORY=on 243 | DIRECTORIES="${DIRECTORIES} ${OPTARG}" 244 | else 245 | Error args 246 | fi 247 | ;; 248 | e) #Emacs mode 249 | EMACS=on 250 | TAGDIR=${HOME}/.MKTAGS.lock 251 | ;; 252 | g) #$gtmroutines mode 253 | if [ -z "${gtmroutines}" ] 254 | then 255 | Error env ${OPT} 256 | fi 257 | 258 | if [ "${DIRECTORY}" == "off" ] 259 | then 260 | GTM=on 261 | else 262 | Error args 263 | fi 264 | ;; 265 | h) #help, nullifies other options when present 266 | Usage 267 | 268 | exit 0 269 | ;; 270 | l) #log mode 271 | LOG=on 272 | ;; 273 | q) #quiet mode 274 | QUIET=on 275 | ;; 276 | v) #verbose mode 277 | VERBOSE=on 278 | ;; 279 | '?') #invalid option 280 | LOG=off 281 | QUIET=off 282 | 283 | Error option ${OPTARG} 284 | ;; 285 | esac 286 | done 287 | 288 | shift $((OPTIND - 1)) 289 | 290 | #getopts doesn't handle a single - 291 | if [ "$1" == "-" ] 292 | then 293 | Error option 294 | fi 295 | 296 | #turn on quiet mode when not connected to a controlling terminal 297 | if [ "`tty`" == "not a tty" ] 298 | then 299 | QUIET=on 300 | fi 301 | 302 | if [ "${LOG}" == "on" ] 303 | then 304 | #create a log directory if there isn't already one 305 | if [ ! -d ${HOME}/log ] 306 | then 307 | mkdir ${HOME}/log 308 | fi 309 | 310 | LOGFILE=${HOME}/log/`basename $0 .sh`.log 311 | fi 312 | 313 | Log notice "Started ${SCRIPT} ; User: ${USER} ; `date`" 314 | 315 | if ! which ctags &> /dev/null 316 | then 317 | Error ctags 318 | fi 319 | 320 | if ! ctags --version | grep -qi "Exuberant Ctags" 321 | then 322 | Error version 323 | fi 324 | 325 | if [ "${GTM}" == "on" ] 326 | then 327 | if [ $# -ne 0 ] 328 | then 329 | Error args 330 | fi 331 | 332 | PROGRAM=Mtags_gtm 333 | else 334 | if [ "${DIRECTORY}" == "on" ] 335 | then 336 | PROGRAM="Mtags ${DIRECTORIES}" 337 | fi 338 | 339 | if [ "${PROGRAM}" ] 340 | then 341 | PROGRAM="${PROGRAM} $@" 342 | else 343 | PROGRAM="Mtags $@" 344 | fi 345 | fi 346 | 347 | #using a lock directory avoids a race condition 348 | if mkdir ${TAGDIR} 2> /dev/null 349 | then 350 | #trap common signals and clean up working lock directory on exit 351 | trap "rm -rf ${TAGDIR}; exit 127" SIGINT SIGQUIT SIGABRT SIGTERM 352 | 353 | echo "$$" > ${TAGDIR}/pid 354 | 355 | Log notice "Stored the PID: $$ in ${TAGDIR}/pid" 356 | else 357 | if [ -f ${TAGDIR} ] 358 | then 359 | Log err "May need to remove the ${TAGDIR} file to run ${SCRIPT}" 360 | elif [ -f ${TAGDIR}/pid ] 361 | then 362 | PID=`cat ${TAGDIR}/pid 2> /dev/null` 363 | 364 | if ! ps -p ${PID} &> /dev/null 365 | then 366 | Log err "May need to remove the ${TAGDIR} directory to run ${SCRIPT}" 367 | fi 368 | else 369 | Log err "May need to remove the ${TAGDIR} directory to run ${SCRIPT}" 370 | fi 371 | 372 | Error running 373 | fi 374 | 375 | TAGFILE=${TAGDIR}/mtags 376 | ARGS="-f ${TAGFILE} -u" 377 | 378 | if [ "${EMACS}" == "on" ] 379 | then 380 | TAGFILE=${TAGDIR}/MTAGS 381 | ARGS="-f ${TAGFILE} -e" 382 | fi 383 | 384 | if [ "${VERBOSE}" == "on" ] 385 | then 386 | ARGS="${ARGS}V" 387 | fi 388 | 389 | if [ "${DIRECTORY}" == "on" -o "${GTM}" == "on" ] 390 | then 391 | ARGS="${ARGS}R" 392 | fi 393 | 394 | if [ "${GTM}" == "on" ] 395 | then 396 | ARGS="${ARGS} --exclude=gtmsecshrdir" #gtmsecshrdir is owned by root 397 | fi 398 | 399 | ${PROGRAM} 400 | 401 | FILE=`basename ${TAGFILE}` 402 | 403 | if [ "${GTM}" == "on" ] 404 | then 405 | MTAGFILE="${HOME}/.${FILE}" 406 | else 407 | MTAGFILE=${FILE} 408 | fi 409 | 410 | if [ "${EMACS}" == "on" ] 411 | then 412 | awk -F'\t' ' 413 | BEGIN { 414 | FLAG = 0 415 | FS = "\x7F" 416 | } 417 | 418 | { 419 | if ($0 == "\f") { 420 | print $0 421 | 422 | FLAG = 1 423 | 424 | next 425 | } 426 | 427 | if (FLAG == 1) { 428 | ROUTINE = $0 429 | 430 | sub("^.*/", "", ROUTINE) 431 | sub(",.*", "", ROUTINE) 432 | sub("_", "%", ROUTINE) 433 | sub("\\.m", "", ROUTINE) 434 | 435 | FLAG = 0 436 | 437 | print $0 438 | 439 | next 440 | } else { 441 | TEXT = $1 "\x7F" 442 | LABEL = $2 443 | 444 | sub("\x01.*", "", LABEL) 445 | 446 | LABEL = LABEL ROUTINE 447 | INFO = $2 448 | 449 | sub(".*\x01", "", INFO) 450 | 451 | INFO = "\x01" INFO 452 | 453 | print TEXT LABEL INFO 454 | } 455 | } 456 | ' ${TAGFILE} > ${TAGDIR}/${FILE}.fixed 457 | else 458 | awk -F'\t' ' 459 | { 460 | if ($2 ~ "\\.m") { 461 | ROUTINE = $2 462 | 463 | sub("^.*/", "", ROUTINE) 464 | sub("_", "%", ROUTINE) 465 | sub("\\.m", "", ROUTINE) 466 | 467 | $1 = $1 ROUTINE 468 | } 469 | 470 | OFS = "\t" 471 | 472 | print $0 473 | } 474 | ' ${TAGFILE} > ${TAGDIR}/${FILE}.fixed 475 | 476 | export LC_ALL=C #force ascii sorting, will override locale temporarily 477 | 478 | sed '1,6s/\(!_TAG_FILE_SORTED\t\)0\(.*\)/\11\2/' ${TAGDIR}/${FILE}.fixed | 479 | sort -u -o ${TAGDIR}/${FILE}.fixed 480 | fi 481 | 482 | BUFFER=`cp -f ${TAGDIR}/${FILE}.fixed ${MTAGFILE}` 483 | 484 | if [ "${BUFFER}" ] 485 | then 486 | Log err "${BUFFER}" 487 | fi 488 | 489 | unset BUFFER 490 | 491 | BUFFER=`rm -rf ${TAGDIR}` 492 | 493 | if [ "${BUFFER}" ] 494 | then 495 | Log err "${BUFFER}" 496 | fi 497 | 498 | unset BUFFER 499 | 500 | Log notice "Finished ${SCRIPT} ; User: ${USER} ; `date`" 501 | Log notice "-----------------------------------------------------------" 502 | 503 | exit 0 504 | -------------------------------------------------------------------------------- /doc/KBAWDUMP.1: -------------------------------------------------------------------------------- 1 | .\" Package: Axiom 2 | .\" File: KBAWDUMP.1 3 | .\" Summary: man page for the KBAWDUMP M[UMPS]/GT.M routine 4 | .\" Maintainer: David Wicksell 5 | .\" Last Modified: Oct 21, 2012 6 | .\" 7 | .\" Written by David Wicksell 8 | .\" Copyright © 2011,2012 Fourth Watch Software, LC 9 | .\" 10 | .\" This program is free software: you can redistribute it and/or modify 11 | .\" it under the terms of the GNU Affero General Public License (AGPL) 12 | .\" as published by the Free Software Foundation, either version 3 of 13 | .\" the License, or (at your option) any later version. 14 | .\" 15 | .\" This program is distributed in the hope that it will be useful, 16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | .\" GNU Affero General Public License for more details. 19 | .\" 20 | .\" You should have received a copy of the GNU Affero General Public License 21 | .\" along with this program. If not, see http://www.gnu.org/licenses/. 22 | .\" 23 | .\" 24 | .TH KBAWDUMP 1 "21 Oct 2012" "Version 0.20.3" "Axiom Developer Tools" 25 | 26 | .SH NAME 27 | \fBKBAWDUMP\fP - A M[UMPS]/GT.M routine for use with the Axiom package 28 | 29 | .SH SYNOPSIS 30 | .B mumps -r KBAWDUMP \fPglobal 31 | 32 | .B mumps -r KBAWDUMP \fP'global(subscript[,subscript]...)' 33 | 34 | .B mumps -r KBAWDUMP \fP'-global(subscript[,subscript]...)' 35 | 36 | .B mumps -r GLOBALS^KBAWDUMP 37 | 38 | .B mumps -r GLOBALS^KBAWDUMP \fP: 39 | 40 | 41 | .SH DESCRIPTION 42 | .B KBAWDUMP 43 | is a M[UMPS]/GT.M routine that will display the contents of a MUMPS global, 44 | with or without subscripts. 45 | .PP 46 | .B Note 47 | that if you specify a subscript(s), you must enclose the global reference in 48 | ticks, or single-quotes ('). This is to ensure that your shell doesn't try to 49 | start a subshell when it sees the parens. 50 | .PP 51 | You are not required to supply the initial ^ of a global reference. You may 52 | optionally preceed the global reference with a '-'. The default behavior of 53 | KBAWDUMP is to display all the data of a referenced subscript and all of its 54 | children. By preceding the global reference with a '-', you can suppress the 55 | output of the children of the global reference. You may also use the wildcard 56 | characters '*' and ':'. Using a '*' at a global reference will display all the 57 | possible data values as well as all the children of that subscript. Using a ':' 58 | at a global reference will display all the possible data values of that 59 | subscript, but not its children. You may only use the '*' wildcard as the last 60 | subscript in the global reference. 61 | .PP 62 | .B GLOBALS^KBAWDUMP 63 | is a M[UMPS]/GT.M routine calling point that will display all of the globals 64 | in a GT.M database. You may also specify a range in this form: 65 | .IP 66 | : 67 | .PP 68 | It will then display every global in a GT.M database starting with 69 | and ending with , inclusive. 70 | .PP 71 | If you do not supply a global before the colon, it will start at the first 72 | global in the database. And if you do not supply a global after the colon, it 73 | will end with the last global in the database. 74 | .PP 75 | .B Note 76 | that you must not have any space between the globals and the colon. 77 | .PP 78 | Again, it does not require that you supply the initial ^ of a global reference. 79 | 80 | .SH EXAMPLES 81 | .IP 82 | $ mumps -r KBAWDUMP DD 83 | .IP 84 | $ mumps -r KBAWDUMP 'DD(0,1)' 85 | .IP 86 | $ mumps -r GLOBALS^KBAWDUMP 87 | .IP 88 | $ mumps -r GLOBALS^KBAWDUMP DI:TMP 89 | .IP 90 | $ mumps -r GLOBALS^KBAWDUMP DI: 91 | .IP 92 | $ mumps -r GLOBALS^KBAWDUMP :TMP 93 | 94 | .SH BUGS 95 | There are no known bugs, but KBAWDUMP has to deal with MUMPS syntax, 96 | so there are more than likely always going to be around 3 bugs. 97 | 98 | .SH AUTHOR 99 | Written by David Wicksell 100 | -------------------------------------------------------------------------------- /doc/lorikeem.1: -------------------------------------------------------------------------------- 1 | .\" Package: LorikeeM MUMPS Developer Tools 2 | .\" File: lorikeem.1 3 | .\" Summary: man page for LorikeeM 4 | .\" Maintainer: John Willis 5 | .\" Last Modified: 16 Jul 2017 6 | .\" 7 | .\" Written by John Willis 8 | .\" Copyright © 2013, 2017 Coherent Logic Development LLC 9 | .\" 10 | .\" This program is free software: you can redistribute it and/or modify 11 | .\" it under the terms of the GNU Affero General Public License (AGPL) 12 | .\" as published by the Free Software Foundation, either version 3 of 13 | .\" the License, or (at your option) any later version. 14 | .\" 15 | .\" This program is distributed in the hope that it will be useful, 16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | .\" GNU Affero General Public License for more details. 19 | .\" 20 | .\" You should have received a copy of the GNU Affero General Public License 21 | .\" along with this program. If not, see http://www.gnu.org/licenses/. 22 | .\" 23 | .\" 24 | .TH LORIKEEM 1 "16 Jul 2017" "Version 0.99.7" "LorikeeM MUMPS Developer Tools" 25 | 26 | .SH NAME 27 | \fBlorikeem\fP - MUMPS programmer's editor 28 | 29 | .SH SYNOPSIS 30 | .B lorikeem 31 | .BI "[\fIFILE\fP]" 32 | 33 | .SH DESCRIPTION 34 | 35 | .B LorikeeM 36 | is a GNU Emacs major mode and auxiliary utilities which turn the GNU Emacs 37 | environment into a MUMPS programmer's editor. 38 | 39 | .SH EXAMPLE 40 | 41 | LorikeeM is typically run from the command line, specifying the name of the 42 | routine to edit, as follows: 43 | 44 | $ lorikeem ROUTINE.m 45 | 46 | This will open ROUTINE.m in GNU Emacs with the LorikeeM major mode enabled. 47 | 48 | .SH GLOBAL LOOKUP 49 | 50 | LorikeeM provides a facility for viewing the value of any MUMPS global from 51 | within the editor. For this to work, the KBAWDUMP.m routine (packaged with 52 | the LorikeeM distribution) must be placed in a location where it can be 53 | accessed by your environment. 54 | 55 | To use global lookup, position the cursor over the global you wish to 56 | examine, and perform one of the following actions: 57 | 58 | * Press the 59 | .B F6 60 | key on your keyboard 61 | 62 | * Type 63 | .B M-x lkm-global-at-point 64 | 65 | * Select 66 | .B Examine Global at Cursor 67 | from the LorikeeM menu 68 | 69 | To examine a global that is not in the current buffer, perform one of the 70 | following actions: 71 | 72 | * Press 73 | .B F7 74 | on your keyboard 75 | 76 | * Type 77 | .B M-x lkm-gtm-global-lookup 78 | 79 | * Select 80 | .B Examine Global 81 | from the LorikeeM menu 82 | 83 | .B NOTE: 84 | The global lookup feature essentially performs a ZWRITE on the selected 85 | or typed global. This can be a huge time and memory drain, especially 86 | for very large globals, as found in e.g. VistA. 87 | 88 | Lookup of a single, specific subscript is planned for a future release. 89 | 90 | .SH ROUTINE LOOKUP 91 | 92 | This facility allows you to jump from a routine reference to its definition 93 | using a tagfile created by Exuberant CTAGS. 94 | 95 | To look up a routine, position your cursor over the routine's entryref, and 96 | do one of the following: 97 | 98 | * Select 99 | .B Jump to Routine Defintion 100 | from the LorikeeM menu 101 | 102 | * Press the 103 | .B F8 104 | key on your keyboard 105 | 106 | The script 107 | .B mktags 108 | , located in the 109 | .B bin 110 | subdirectory of your home directory, allows you to create a tagfile in the 111 | unique format required by GNU Emacs. 112 | 113 | To create the tagfile for all the source directories refernced in your 114 | .B $gtmroutines 115 | environment variable, run 116 | .B mktags -eg 117 | from your ~/bin directory. You will need to run this script each time you 118 | make a change to your MUMPS routines. 119 | 120 | For more advanced usage of 121 | .B mktags 122 | , refer to 123 | .B mktags(1) 124 | 125 | .SH SYMBOL COMPLETION 126 | 127 | LorikeeM provides symbol and keyword completion. To use it, position your 128 | cursor over the incomplete keyword and press the 129 | .B F5 130 | key or type 131 | .B M-x lkm-complete-symbol 132 | 133 | LorikeeM will expand the short form of the MUMPS command at the cursor position 134 | to its long form, complete the intrinsic function's name at the cursor position, 135 | or provide you with a list of possible completions from which you can select 136 | the desired command or intrinsic function. 137 | 138 | .SH ROUTINE COMPILATION 139 | 140 | LorikeeM allows you to compile the currently-loaded routine. To do this, perform 141 | one of the following actions: 142 | 143 | * Press the 144 | .B F9 145 | key on your keyboard 146 | 147 | * Select 148 | .B Compile Current Buffer 149 | from the LorikeeM menu 150 | 151 | .SH API TEMPLATES 152 | 153 | LorikeeM integrates YASnippet functionality to provide "IntelliSense"-style parameter 154 | completion for all of the MUMPS 1995 intrinsic functions and part of the VistA API. 155 | 156 | API templates are triggered by typing the opening paren of the function's actuallist. 157 | Pressing the 158 | .B TAB 159 | or 160 | .B SHIFT-TAB 161 | keys will navigate forward and reverse, respectively, through the parameters, highlighting the 162 | parameter names so they will be replaced when you begin typing. Some parameters will prompt 163 | you with a menu of options from which you can choose. 164 | 165 | .B NOTE: 166 | Current VistA API support is limited to the Fileman Database Server (DBS) API. 167 | 168 | The files supporting these APIs are located at 169 | .B ~/.emacs.d/plugins/yasnippet/snippets/mumps-mode 170 | 171 | .SH BUGS 172 | 173 | * Syntax coloring for comments sometimes breaks when the comment includes MUMPS commands or intrinsic functions 174 | 175 | * Most of the functionality of 176 | .B KBAWDUMP(1) 177 | is not exposed by LorikeeM 178 | 179 | * The API templates provided only support the uppercase versions of intrinsic functions. 180 | 181 | * LorikeeM only supports FIS GT.M currently. Support for InterSystems Cache', MUMPSV1, and FreeM is 182 | planned for the 1.0 release. 183 | 184 | Before a 1.0 release will be considered, the above bugs must be fixed. 185 | 186 | .SH AUTHOR 187 | 188 | Written by John Willis 189 | 190 | Inspired by David Wicksell's 191 | .B AxioM Developer Tools 192 | , which provides similar functionality for Bram Moolenar's 193 | .B vim 194 | editor. 195 | 196 | Includes functionality from the 197 | .B YASnippet 198 | templating library for Emacs 199 | 200 | Also inspired by John May's mumps-mode as found at http://www.mombu.com/programming/mumps/t-emacs-mumps-mode-3143202.html 201 | 202 | .SH SEE ALSO 203 | axiom(1), emacs(1), GNU Emacs texinfo documentation, http://www.coherent-logic.com/lorikeem 204 | -------------------------------------------------------------------------------- /doc/mktags.1: -------------------------------------------------------------------------------- 1 | .\" Package: Axiom 2 | .\" File: mktags.1 3 | .\" Summary: man page for the mktags shell script 4 | .\" Maintainer: David Wicksell 5 | .\" Last Modified: Oct 20, 2012 6 | .\" 7 | .\" Written by David Wicksell 8 | .\" Copyright © 2011,2012 Fourth Watch Software, LC 9 | .\" 10 | .\" This program is free software: you can redistribute it and/or modify 11 | .\" it under the terms of the GNU Affero General Public License (AGPL) 12 | .\" as published by the Free Software Foundation, either version 3 of 13 | .\" the License, or (at your option) any later version. 14 | .\" 15 | .\" This program is distributed in the hope that it will be useful, 16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | .\" GNU Affero General Public License for more details. 19 | .\" 20 | .\" You should have received a copy of the GNU Affero General Public License 21 | .\" along with this program. If not, see http://www.gnu.org/licenses/. 22 | .\" 23 | .\" 24 | .TH MKTAGS 1 "20 Oct 2012" "Version 0.20.3" "Axiom Developer Tools" 25 | 26 | .SH NAME 27 | \fBmktags\fP - A script to build a tags file for use with the Axiom package 28 | 29 | .SH SYNOPSIS 30 | .B mktags 31 | .BI "[-elqv] [-d \fIDIRECTORY\fP | \fIFILE\fP]+" 32 | 33 | .B mktags 34 | .BI "[-elqv] -g" 35 | 36 | .B mktags 37 | .BI -h 38 | 39 | .SH DESCRIPTION 40 | .B mktags 41 | is a shell script that will create a tags file containing MUMPS labels or 42 | entryrefs for use with the Axiom package. 43 | .PP 44 | Normally you would call it via cron once or more daily to keep your tags file 45 | up to date. 46 | 47 | .SH OPTIONS 48 | The following command line flags are optional. At least -g, or a directory or 49 | list of directories, with or without, a file or list of files, is required. 50 | .IP -d 51 | Supply a directory name after this option, and mktags will recursively search 52 | it and create a tags file, called MTAGS, in the current working directory. 53 | You can supply as many -d flags as you want, but can only give each one the 54 | name of one directory. 55 | .IP -e 56 | Run in Emacs mode, building a tags file called MTAGS or ~/.MTAGS in Emacs 57 | format. 58 | .IP -h 59 | Display a helpful usage message and exit. 60 | .IP -g 61 | Parse the $gtmroutines environment variable, going through the specified 62 | directories, building a tags file called ~/.mtags or MTAGS. 63 | .IP -l 64 | Turn on logging. Nothing is logged unless this flag is used. It will log to 65 | the file ~/log/mktags.log. If it is an error message, and not just a notice, 66 | it will also log to the system log file. E.g. 67 | 68 | /var/log/messages or /var/log/syslog 69 | .IP -q 70 | Run in quiet mode. This will ensure that no notice or error messages are ever 71 | written out to the screen. It works independently of the -l and -v options. 72 | .IP -v 73 | Run in verbose mode. This will turn on a very verbose logging of what the tag 74 | building command, ctags, is doing. It works independently of the -l and -q 75 | options. 76 | 77 | .SH EXAMPLE 78 | Normally mktags is run from the command line, on each directory listed in the 79 | $gtmroutines environment variable. E.g. 80 | 81 | $ mktags -g 82 | 83 | If you want, you can run it from cron by adding it to your crontab file. Keep 84 | in mind that you will either need to use the full path to mktags, or you will 85 | need to define $PATH to include the ~/bin/ directory where mktags is installed, 86 | in your crontab file. If you are using the -g option, you will need to make 87 | sure to source the file that builds the $gtmroutines environment variable, in 88 | your crontab entry, since the -g option requires that it be defined. Running 89 | mktags from cron could be done to keep your tags file up-to-date. Then it will 90 | keep up with added, removed, or modified MUMPS routines. Example crontab entry: 91 | 92 | SHELL=/bin/bash 93 | PATH=~/bin:/usr/bin:/bin 94 | 00 20 * * * . set_env && mktags -gl 95 | .SH EXIT CODES 96 | 0 Success 97 | 98 | 1 ctags is not installed 99 | 100 | 2 exuberant-ctags is not installed 101 | 102 | 3 -g option being used without $gtmroutines being defined 103 | 104 | 4 Invalid option 105 | 106 | 5 Not enough arguments supplied 107 | 108 | 6 mktags is already running 109 | 110 | 7 Bad error code (Should never happen) 111 | 112 | 127 User interrupted program execution: E.g. CTRL-C/SIGINT 113 | 114 | .SH BUGS 115 | There are no known bugs. 116 | 117 | .SH AUTHOR 118 | Written by David Wicksell 119 | 120 | .SH SEE ALSO 121 | ctags(1), ctags-exuberant(1), crontab(5), crontab(1), cron(8) 122 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # install.sh 5 | # LorikeeM Installer 6 | # 7 | # Copyright (C) 2013 Coherent Logic Development 8 | # 9 | # Provided under the terms of the GNU Affero General 10 | # Public License V3 11 | # 12 | 13 | export installer_caption="LorikeeM M Developer Tools" 14 | 15 | function welcome_message 16 | { 17 | installer_text="Welcome to the LorikeeM M Developer Tools installer." 18 | installer_text="${installer_text}\n\n" 19 | installer_text="${installer_text}This program will help you install " 20 | installer_text="${installer_text}LorikeeM onto your computer.\n\n" 21 | installer_text="${installer_text}LorikeeM requires YottaDB 1.10 or FIS GT.M and " 22 | installer_text="${installer_text}GNU Emacs 24 or newer to function.\n" 23 | installer_text="${installer_text}You appear to be running ${DISTRIB_ID}.\n\n" 24 | installer_text="${installer_text}Choose OK to continue." 25 | 26 | whiptail --title "${installer_caption}" --msgbox "${installer_text}" 15 75 27 | } 28 | 29 | function check_distro 30 | { 31 | DISTRIB_ID=`lsb_release -i -s` 32 | case ${DISTRIB_ID} in 33 | Ubuntu) 34 | export PACKAGE_MANAGER="apt-get install" 35 | ;; 36 | Debian) 37 | export PACKAGE_MANAGER="apt-get install" 38 | ;; 39 | Fedora) 40 | export PACKAGE_MANAGER="yum install" 41 | ;; 42 | CentOS) 43 | export PACKAGE_MANAGER="yum install" 44 | ;; 45 | esac 46 | export DISTRIB_ID 47 | } 48 | 49 | function check_for_whiptail 50 | { 51 | which whiptail > /dev/null 52 | if [ $? != 0 ]; then 53 | echo "This installer requires whiptail(1) to function." 54 | exit 55 | fi 56 | } 57 | 58 | function check_for_root 59 | { 60 | if [ $EUID != 0 ]; then 61 | whiptail --title "${installer_caption}" --msgbox "You must have root privileges in order to install LorikeeM" 12 75 62 | exit 63 | fi 64 | } 65 | 66 | 67 | function check_for_emacs 68 | { 69 | which emacs > /dev/null 70 | if [ $? != 0 ]; then 71 | whiptail --title "${installer_caption}" \ 72 | --yesno "GNU Emacs does not appear to be installed. Do you wish to install it?" 12 75 73 | case $? in 74 | 0) 75 | sudo ${PACKAGE_MANAGER} emacs 76 | ;; 77 | 1) 78 | echo "Please install GNU Emacs 23 or later and try again." 79 | exit 80 | ;; 81 | esac 82 | fi 83 | } 84 | 85 | function check_create_directories 86 | { 87 | whiptail --title "${installer_caption}" \ 88 | --infobox "Creating directories..." 12 75 89 | 90 | if [ ! -d "${HOME}/.emacs.d" ]; then 91 | mkdir ${HOME}/.emacs.d 92 | fi 93 | 94 | if [ ! -d "${HOME}/.emacs.d/plugins" ]; then 95 | mkdir ${HOME}/.emacs.d/plugins 96 | fi 97 | 98 | if [ ! -d "${HOME}/.emacs.d/plugins/lorikeem" ]; then 99 | mkdir ${HOME}/.emacs.d/plugins/lorikeem 100 | fi 101 | 102 | if [ ! -d "${HOME}/bin" ]; then 103 | mkdir ${HOME}/bin 104 | fi 105 | 106 | if [ ! -d "${HOME}/man/man1" ]; then 107 | mkdir -p ${HOME}/man/man1 108 | fi 109 | 110 | if [ ! -f "${HOME}/.emacs" ]; then 111 | touch ${HOME}/.emacs 112 | fi 113 | } 114 | 115 | function backup_file 116 | { 117 | BACKUP_TIMESTAMP=`date +%Y%m%d%H%M%S` 118 | BACKUP_EXTENSION="lorikeem.${BACKUP_TIMESTAMP}" 119 | if [ -f "$1" ]; then 120 | mv $1 $1.${BACKUP_EXTENSION} 121 | fi 122 | } 123 | 124 | function copy_lorikeem_elisp 125 | { 126 | whiptail --title "${installer_caption}" \ 127 | --infobox "Copying LorikeeM..." 12 75 128 | 129 | backup_file ${HOME}/.emacs.d/plugins/lorikeem/lorikeem.el 130 | 131 | cp src/lorikeem/lorikeem.el ${HOME}/.emacs.d/plugins/lorikeem/ 132 | } 133 | 134 | function copy_yasnippet 135 | { 136 | whiptail --title "${installer_caption}" \ 137 | --infobox "Installing YASnippet..." 12 75 138 | 139 | 140 | if [ -d "${HOME}/.emacs.d/plugins/yasnippet" ]; then 141 | whiptail --title "${installer_caption}" \ 142 | --yesno "YASnippet appears to have been previously installed.\n\nDo you wish to back up the current version?" 12 75 143 | 144 | if [ $? == 0 ]; then 145 | BACKUP_TIMESTAMP=`date +%Y%m%d%H%M%S` 146 | BACKUP_FILE="${HOME}/.emacs.d/plugins/yasnippet_${BACKUP_TIMESTAMP}.tar" 147 | tar cvf ${BACKUP_FILE} ${HOME}/.emacs.d/plugins/yasnippet 148 | fi 149 | 150 | rm -rf ${HOME}/.emacs.d/plugins/yasnippet 151 | 152 | fi 153 | cp -r src/yasnippet ${HOME}/.emacs.d/plugins 154 | } 155 | 156 | function parse_gtmroutines 157 | { 158 | local DIR DIRS 159 | 160 | for DIR in ${gtmroutines} 161 | do 162 | if [[ ${DIR} != ${DIR/"("/} ]] 163 | then 164 | DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1` 165 | elif [[ ${DIR} != ${DIR/")"/} ]] 166 | then 167 | DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1` 168 | elif [ "${DIR: -3}" == ".so" ] 169 | then 170 | DIR=`dirname ${DIR}` 171 | elif ! ls ${DIR}/*.m &> /dev/null 172 | then 173 | DIR=`dirname ${DIR}` 174 | fi 175 | DIRS="${DIRS} ${DIR}" 176 | done 177 | 178 | export ROUTINE_DIRS=${DIRS} 179 | } 180 | 181 | function choose_routine_path 182 | { 183 | parse_gtmroutines 184 | 185 | whiptail_cmd="--title \"${installer_caption}\" --noitem --menu \"Where would you like to install Lorikeem's MUMPS routines?\" 15 76 4 " 186 | 187 | for DIR in ${ROUTINE_DIRS} 188 | do 189 | whiptail_cmd="${whiptail_cmd} \"${DIR}\" \" \"" 190 | done 191 | 192 | whiptail_cmd="${whiptail_cmd} \"Other\" \" \"" 193 | 194 | export CHOSEN_ROUTINE_PATH=$(eval whiptail ${whiptail_cmd} 3>&1 1>&2 2>&3) 195 | 196 | if [ ${CHOSEN_ROUTINE_PATH} == "Other" ]; then 197 | export CHOSEN_ROUTINE_PATH=$(whiptail --inputbox "Custom MUMPS routine location:" 8 78 ${HOME} --title "${installer_caption}" 3>&1 1>&2 2>&3) 198 | if [ ! -d "${CHOSEN_ROUTINE_PATH}" ]; then 199 | mkdir "${CHOSEN_ROUTINE_PATH}" 200 | fi 201 | fi 202 | 203 | if [ $? != 0 ]; then 204 | exit 205 | fi 206 | } 207 | 208 | function copy_mumps_routines 209 | { 210 | choose_routine_path 211 | 212 | cp src/mumps/*.m ${CHOSEN_ROUTINE_PATH} 213 | } 214 | 215 | function copy_manpages 216 | { 217 | whiptail --title "${installer_caption}" \ 218 | --infobox "Installing documentation..." 12 75 219 | 220 | cp -p doc/mktags.1 doc/lorikeem.1 doc/KBAWDUMP.1 ${HOME}/man/man1/ 221 | gzip -f9 ${HOME}/man/man1/{mktags,KBAWDUMP,lorikeem}.1 222 | 223 | if [ "${OS}" == "Ubuntu" -o "${OS}" == "LinuxMint" ]; then 224 | export MANPATH=:~/man 225 | mandb -q 226 | else 227 | if grep -q MANPATH ~/.bashrc 228 | then 229 | # do nothing 230 | echo "do nothing" > /dev/null 231 | else 232 | echo >> ~/.bashrc 233 | echo "export MANPATH=\$HOME/man:`manpath`" >> ~/.bashrc 234 | fi 235 | fi 236 | } 237 | 238 | function update_emacs_config 239 | { 240 | whiptail --title "${installer_caption}" \ 241 | --infobox "Updating Emacs configuration..." 12 75 242 | 243 | cat src/lorikeem/lorikeem-dotemacs.el >> ${HOME}/.emacs 244 | } 245 | 246 | function copy_binaries 247 | { 248 | whiptail --title "${installer_caption}" \ 249 | --infobox "Installing binaries..." 12 75 250 | 251 | cp bin/* ${HOME}/bin 252 | } 253 | 254 | function update_search_path 255 | { 256 | whiptail --title "${installer_caption}" \ 257 | --infobox "Updating search path..." 12 75 258 | 259 | cat src/lorikeem/lorikeem-path.sh >> ${HOME}/.bashrc 260 | } 261 | 262 | function install_crontab 263 | { 264 | whiptail --title "${installer_caption}" \ 265 | --infobox "Setting up scheduled tasks..." 12 75 266 | 267 | crontab -l > tmp_cron 268 | echo "0 * * * * mktags -e -g" >> tmp_cron 269 | crontab tmp_cron 270 | rm tmp_cron 271 | } 272 | 273 | function build_tags 274 | { 275 | whiptail --title "${installer_caption}" \ 276 | --infobox "Building ${HOME}/.MTAGS for routine cross-referencing..." 12 75 277 | 278 | ${HOME}/bin/mktags -e -g 279 | } 280 | 281 | function done_message 282 | { 283 | installer_text="LorikeeM has been successfully installed.\n\n" 284 | installer_text="${installer_text}You may start LorikeeM by typing\n\nlorikeem [filespec]\n\n" 285 | installer_text="${installer_text}at the shell prompt." 286 | whiptail --title "${installer_caption}" \ 287 | --msgbox "${installer_text}" 15 75 288 | } 289 | 290 | check_for_whiptail 291 | check_distro 292 | welcome_message 293 | check_for_emacs 294 | copy_mumps_routines 295 | check_create_directories 296 | copy_manpages 297 | update_emacs_config 298 | copy_lorikeem_elisp 299 | copy_yasnippet 300 | copy_binaries 301 | update_search_path 302 | install_crontab 303 | build_tags 304 | done_message 305 | -------------------------------------------------------------------------------- /src/lorikeem/lorikeem-dotemacs.el: -------------------------------------------------------------------------------- 1 | 2 | ;;//LORIKEEM START 3 | (add-to-list 'load-path "~/.emacs.d/plugins/lorikeem") 4 | (add-to-list 'load-path "~/.emacs.d/plugins/yasnippet") 5 | (require 'yasnippet) 6 | (yas/global-mode 1) 7 | (autoload 'mumps-mode "lorikeem" "MUMPS mode" t) 8 | (setq auto-mode-alist (append '(("\\.m$" . mumps-mode)) auto-mode-alist)) 9 | (setq auto-mode-alist (append '(("\\.ewd$" . xml-mode)) auto-mode-alist)) 10 | ;;LORIKEEM END// -------------------------------------------------------------------------------- /src/lorikeem/lorikeem-path.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | #//LORIKEEM 4 | export PATH=${PATH}:${HOME}/bin 5 | #LORIKEEM// -------------------------------------------------------------------------------- /src/lorikeem/lorikeem.el: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; 3 | ;; LorikeeM MUMPS Developer Tools 4 | ;; 5 | ;; Provides syntax highlighting and global dump for GNU Emacs 6 | ;; 7 | ;; Note that I have concentrated mostly on GT.M/YottaDB syntax here. the 8 | ;; list of keywords and functions comes from Edition 6.1 of 9 | ;; Jon Diamond's "Standard M Pocket Guide." I have not left out 10 | ;; any InterSystems Cache-specific syntax, but have not tested 11 | ;; its use on any Cache-specific code. 12 | ;; 13 | ;; Written by John Willis 14 | ;; 15 | ;; 16 | ;; Copyright (C) 2010, 2012, 2013, 2017 Coherent Logic Development LLC 17 | ;; 18 | ;; This program is free software: you can redistribute it and/or modify 19 | ;; it under the terms of the GNU Affero General Public License (AGPL) 20 | ;; as published by the Free Software Foundation, either version 3 of 21 | ;; the License, or (at your option) any later version. 22 | ;; 23 | ;; This program is distributed in the hope that it will be useful, 24 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | ;; GNU Affero General Public License for more details. 27 | ;; 28 | ;; You should have received a copy of the GNU Affero General Public License 29 | ;; along with this program. If not, see http://www.gnu.org/licenses/. 30 | ;; 31 | ;; 32 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 33 | 34 | 35 | 36 | ;; hooks for run before mode run 37 | (defvar mumps-mode-hook nil) 38 | 39 | 40 | ;; keywords for syntax highlighting 41 | (defvar mumps-keywords-ucase-abbrev 42 | '("B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "TC" "TRE" "TRO" "TS" "U" "V" "W" "X" "ZA" "ZB" "ZD" "ZH" "ZHO" "ZI" "ZK" "ZL" "ZN" "ZP" "ZQ" "ZR" "ZS" "ZSY" "ZTC" "ZT" "ZTS" "ZU" "ZW") 43 | "MUMPS uppercase abbreviated keywords") 44 | 45 | (defvar mumps-keywords-lcase-abbrev 46 | '("b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "tc" "tre" "tro" "ts" "u" "v" "w" "x" "za" "zb" "zd" "zh" "zho" "zi" "zk" "zl" "zn" "zp" "zq" "zr" "zs" "zsy" "ztc" "zt" "zts" "zu" "zw") 47 | "MUMPS lowercase abbreviated keywords") 48 | 49 | (defvar mumps-keywords-ucase-full 50 | '("BREAK" "CLOSE" "CONTINUE" "DO" "ELSE" "ELSEIF" "FOR" "GOTO" "HALT" "HANG" "IF" "JOB" "KILL" "LOCK" "MERGE" "NEW" "OPEN" "PRINT" "QUIT" "READ" "SET" "TCOMMIT" "TRESTART" "TROLLBACK" "TSTART" "USE" "VIEW" "WHILE" "WRITE" "XECUTE" "ZALLOCATE" "ZBREAK" "ZDEALLOCATE" "ZHANG" "ZHOROLOG" "ZINSERT" "ZKILL" "ZLOAD" "ZNSPACE" "ZPRINT" "ZQUIT" "ZREMOVE" "ZSAVE" "ZSYNC" "ZSYSTEM" "ZTCOMMIT" "ZTRAP" "ZTSTART" "ZUSE" "ZWITHDRAW" "ZWRITE" "ZZDUMP") 51 | "MUMPS uppercase full-length keywords") 52 | 53 | (defvar mumps-keywords-lcase-full 54 | '("break" "close" "continue" "do" "else" "elseif" "for" "goto" "halt" "hang" "if" "job" "kill" "lock" "merge" "new" "open" "print" "quit" "read" "set" "tcommit" "trestart" "trollback" "tstart" "use" "view" "while" "write" "xecute" "zallocate" "zbreak" "zdeallocate" "zhang" "zhorolog" "zinsert" "zkill" "zload" "znspace" "zprint" "zquit" "zremove" "zsave" "zsync" "zsystem" "ztcommit" "ztrap" "ztstart" "zuse" "zwithdraw" "zwrite" "zzdump") 55 | "MUMPS lowercase full-length keywords") 56 | 57 | (defvar mumps-functions-ucase-abbrev 58 | '("A" "C" "D" "E" "F" "FN" "G" "IN" "I" "J" "L" "LI" "LB" "LD" "LF" "LFS" "LG" "LL" "LS" "LTS" "NA" "N" "NUM" "O" "P" "Q" "QL" "QS" "R" "S" "ST" "T" "TR" "V" "ZBA" "ZBC" "ZBF" "ZBG" "ZBL" "ZBN" "ZB" "ZBSE" "ZBST" "ZBX" "ZCVT" "ZC" "ZD" "ZDH" "ZDT" "ZDTH" "ZDEV" "ZI" "ZO" "ZP" "ZSE" "ZSO" "ZT" "ZTH" "ZTL" "ZU") 59 | "MUMPS uppercase abbreviated functions") 60 | 61 | (defvar mumps-functions-lcase-abbrev 62 | '("a" "c" "d" "e" "f" "fn" "g" "in" "i" "j" "l" "li" "lb" "ld" "lf" "lfs" "lg" "ll" "ls" "lts" "na" "n" "num" "o" "p" "q" "ql" "qs" "r" "s" "st" "t" "tr" "v" "zba" "zbc" "zbf" "zbg" "zbl" "zbn" "zb" "zbse" "zbst" "zbx" "zcvt" "zc" "zd" "zdh" "zdt" "zdth" "zdev" "zi" "zo" "zp" "zse" "zso" "zt" "zth" "ztl" "zu") 63 | "MUMPS lowercase abbreviated functions") 64 | 65 | (defvar mumps-functions-ucase-full 66 | '("ASCII" "BIT" "BITCOUNT" "BITFIND" "BITLOGIC" "CASE" "CHAR" "DATA" "EXTRACT" "FACTOR" "FIND" "FNUMBER" "GET" "INCREMENT" "INUMBER" "ISOBJECT" "ISVALIDNUM" "JUSTIFY" "LENGTH" "LIST" "LISTBUILD" "LB" "LISTDATA" "LISTFIND" "LISTFROMSTRING" "LISTGET" "LISTLENGTH" "LISTNEXT" "LISTSAME" "LISTTOSTRING" "NAME" "NEXT" "NORMALIZE" "NUMBER" "ORDER" "PIECE" "QLENGTH" "QSUBSCRIPT" "QUERY" "RANDOM" "REVERSE" "SELECT" "SORTBEGIN" "SORTEND" "STACK" "SYSTEM" "TEXT" "TRANSLATE" "VIEW" "ZABS" "ZARCCOS" "ZARCSIN" "ZARCTAN" "ZBAND" "ZBCOUNT" "ZBFIND" "ZBGET" "ZBIT" "ZZBITAND" "ZBITCOUNT" "ZBITFIND" "ZBITGET" "ZBITLEN" "ZBITNOT" "ZBITOR" "ZBITSET" "ZBITSTR" "ZBITXOR" "ZBLEN" "ZBNOT" "ZBOOLEAN" "ZBOR" "ZBSET" "ZBSTR" "ZBXOR" "ZCONVERT" "ZCVT" "ZCOS" "ZCOT" "ZCRC" "ZCSC" "ZCYC" "ZDATE" "ZDATEH" "ZDATETIME" "ZDATETIMEH" "ZDEVICE" "ZEXP" "ZF" "ZHEX" "ZINCREMENT" "ZINFO" "ZLN" "ZLOG" "ZMESSAGE" "ZNAME" "ZNEXT" "ZOBJCLASSMETHOD" "ZOBJPROPERTY" "ZORDER" "ZPARSE" "ZPOWER" "ZPREVIOUS" "ZSEARCH" "ZSEC" "ZSEEK" "ZSIN" "ZSOCKET" "ZSORT" "ZSQR" "ZSTRIP" "ZTAN" "ZTEXP" "ZTIME" "ZTIMEH" "ZTLOG" "ZTRNLMN" "ZUCI") 67 | "MUMPS uppercase full-length functions") 68 | 69 | (defvar mumps-functions-lcase-full 70 | '("ascii" "bit" "bitcount" "bitfind" "bitlogic" "case" "char" "data" "extract" "factor" "find" "fnumber" "get" "increment" "inumber" "isobject" "isvalidnum" "justify" "length" "list" "listbuild" "lb" "listdata" "listfind" "listfromstring" "listget" "listlength" "listnext" "listsame" "listtostring" "name" "next" "normalize" "number" "order" "piece" "qlength" "qsubscript" "query" "random" "reverse" "select" "sortbegin" "sortend" "stack" "system" "text" "translate" "view" "zabs" "zarccos" "zarcsin" "zarctan" "zband" "zbcount" "zbfind" "zbget" "zbit" "zzbitand" "zbitcount" "zbitfind" "zbitget" "zbitlen" "zbitnot" "zbitor" "zbitset" "zbitstr" "zbitxor" "zblen" "zbnot" "zboolean" "zbor" "zbset" "zbstr" "zbxor" "zconvert" "zcvt" "zcos" "zcot" "zcrc" "zcsc" "zcyc" "zdate" "zdateh" "zdatetime" "zdatetimeh" "zdevice" "zexp" "zf" "zhex" "zincrement" "zinfo" "zln" "zlog" "zmessage" "zname" "znext" "zobjclassmethod" "zobjproperty" "zorder" "zparse" "zpower" "zprevious" "zsearch" "zsec" "zseek" "zsin" "zsocket" "zsort" "zsqr" "zstrip" "ztan" "ztexp" "ztime" "ztimeh" "ztlog" "ztrnlmn" "zuci") 71 | "MUMPS lowercase full-length functions") 72 | 73 | (defvar mumps-sv-ucase-abbrev 74 | '("D" "EC" "ES" "ET" "H" "IO" "J" "K" "P" "Q" "R" "ST" "S" "SY" "T" "TL" "TR" "X" "Y" "ZA" "ZAL" "ZB" "ZCH" "ZCM" "ZCO" "ZCS" "ZCL" "ZDA" "ZD" "ZED" "ZEO" "ZE" "ZG" "ZH" "ZINT" "ZINI" "ZIO" "ZJ" "ZK" "ZL" "ZMAXPTI" "ZMO" "ZONLN" "ZPATN" "ZPIN" "ZPOUT" "ZPOS" "ZPROM" "ZRE" "ZRO" "ZSO" "ZS" "ZST" "ZSY" "ZTE" "ZUS" "ZUT" "ZV" "ZYER" "ZTDA" "ZTDE" "ZTL" "ZTNAME" "ZTOL" "ZTRI" "ZTS" "ZTUP" "ZTVA" "ZTWO" "ZYRE") 75 | "MUMPS uppercase abbreviated instrinsic SVs") 76 | 77 | (defvar mumps-sv-lcase-abbrev 78 | '("d" "ec" "es" "et" "h" "io" "j" "k" "p" "q" "r" "st" "s" "sy" "t" "tl" "tr" "x" "y" "za" "zal" "zb" "zch" "zcm" "zco" "zcs" "zcl" "zda" "zd" "zed" "zeo" "ze" "zg" "zh" "zint" "zini" "zio" "zj" "zk" "zl" "zmaxpti" "zmo" "zonln" "zpatn" "zpin" "zpout" "zpos" "zprom" "zre" "zro" "zso" "zs" "zst" "zsy" "zte" "zus" "zut" "zv" "zyer" "ztda" "ztde" "ztl" "ztname" "ztol" "ztri" "zts" "ztup" "ztva" "ztwo" "zyre") 79 | "MUMPS lowercase abbreviated instrinsic SVs") 80 | 81 | (defvar mumps-sv-ucase-full 82 | '("DEVICE" "ECODE" "ESTACK" "ETRAP" "HOROLOG" "IO" "JOB" "KEY" "PRINCIPAL" "QUIT" "REFERENCE" "STACK" "STORAGE" "SYSTEM" "TEST" "TLEVEL" "TRESTART" "X" "Y" "ZA" "ZALLOCSTOR" "ZB" "ZCHSET" "ZCMDLINE" "ZCOMPILE" "ZCSTATUS" "ZCLOSE" "ZDATEFORM" "ZDIRECTORY" "ZEDIT" "ZEOF" "ZERROR" "ZGBLDIR" "ZHOROLOG" "ZINTERRUPT" "ZININTERRUPT" "ZIO" "ZJOB" "ZKEY" "ZLEVEL" "ZMAXPTIME" "ZMODE" "ZONLNRBLK" "ZPATNUMERIC" "ZPIN" "ZPOUT" "ZPOSITION" "ZPROMPT" "ZREALSTOR" "ZROUTINES" "ZSOURCE" "ZSTATUS" "ZSTEP" "ZSYSTEM" "ZTEXIT" "ZUSEDSTOR" "ZUT" "ZVERSION" "ZYERROR" "ZTDATA" "ZTDELIM" "ZTLEVEL" "ZTNAME" "ZTOLDVAL" "ZTRIGGEROP" "ZTSLATE" "ZTUPDATE" "ZTVALUE" "ZTWORMHOLE" "ZYRELEASE") 83 | "MUMPS uppercase full-length intrinsic SVs") 84 | 85 | (defvar mumps-sv-lcase-full 86 | '("device" "ecode" "estack" "etrap" "horolog" "io" "job" "key" "principal" "quit" "reference" "stack" "storage" "system" "test" "tlevel" "trestart" "x" "y" "za" "zallocstor" "zb" "zchset" "zcmdline" "zcompile" "zcstatus" "zclose" "zdateform" "zdirectory" "zedit" "zeof" "zerror" "zgbldir" "zhorolog" "zinterrupt" "zininterrupt" "zio" "zjob" "zkey" "zlevel" "zmaxptime" "zmode" "zonlnrblk" "zpatnumeric" "zpin" "zpout" "zposition" "zprompt" "zrealstor" "zroutines" "zsource" "zstatus" "zstep" "zsystem" "ztexit" "zusedstor" "zut" "zversion" "zyerror" "ztdata" "ztdelim" "ztlevel" "ztname" "ztoldval" "ztriggerop" "ztslate" "ztupdate" "ztvalue" "ztwormhole" "zyrelease") 87 | "MUMPS lowercase full-length intrinsic SVs") 88 | 89 | ;; define keywords for completion 90 | (defvar mumps-keywords 91 | '("BREAK" "CLOSE" "CONTINUE" "DO" "ELSE" "ELSEIF" "FOR" "GOTO" "HALT" "HANG" "IF" "JOB" "KILL" "LOCK" "MERGE" "NEW" "OPEN" "PRINT" "QUIT" "READ" "SET" "TCOMMIT" "TRESTART" "TROLLBACK" "TSTART" "USE" "VIEW" "WHILE" "WRITE" "XECUTE" "ZALLOCATE" "ZBREAK" "ZDEALLOCATE" "ZHANG" "ZHOROLOG" "ZINSERT" "ZKILL" "ZLOAD" "ZNSPACE" "ZPRINT" "ZQUIT" "ZREMOVE" "ZSAVE" "ZSYNC" "ZSYSTEM" "ZTCOMMIT" "ZTRAP" "ZTSTART" "ZUSE" "ZWITHDRAW" "ZWRITE" "ZZDUMP" "break" "close" "continue" "do" "else" "elseif" "for" "goto" "halt" "hang" "if" "job" "kill" "lock" "merge" "new" "open" "print" "quit" "read" "set" "tcommit" "trestart" "trollback" "tstart" "use" "view" "while" "write" "xecute" "zallocate" "zbreak" "zdeallocate" "zhang" "zhorolog" "zinsert" "zkill" "zload" "znspace" "zprint" "zquit" "zremove" "zsave" "zsync" "zsystem" "ztcommit" "ztrap" "ztstart" "zuse" "zwithdraw" "zwrite" "zzdump" "ASCII" "BIT" "BITCOUNT" "BITFIND" "BITLOGIC" "CASE" "CHAR" "DATA" "EXTRACT" "FACTOR" "FIND" "FNUMBER" "GET" "INCREMENT" "INUMBER" "ISOBJECT" "ISVALIDNUM" "JUSTIFY" "LENGTH" "LIST" "LISTBUILD" "LB" "LISTDATA" "LISTFIND" "LISTFROMSTRING" "LISTGET" "LISTLENGTH" "LISTNEXT" "LISTSAME" "LISTTOSTRING" "NAME" "NEXT" "NORMALIZE" "NUMBER" "ORDER" "PIECE" "QLENGTH" "QSUBSCRIPT" "QUERY" "RANDOM" "REVERSE" "SELECT" "SORTBEGIN" "SORTEND" "STACK" "SYSTEM" "TEXT" "TRANSLATE" "VIEW" "ZABS" "ZARCCOS" "ZARCSIN" "ZARCTAN" "ZBAND" "ZBCOUNT" "ZBFIND" "ZBGET" "ZBIT" "ZZBITAND" "ZBITCOUNT" "ZBITFIND" "ZBITGET" "ZBITLEN" "ZBITNOT" "ZBITOR" "ZBITSET" "ZBITSTR" "ZBITXOR" "ZBLEN" "ZBNOT" "ZBOOLEAN" "ZBOR" "ZBSET" "ZBSTR" "ZBXOR" "ZCONVERT" "ZCVT" "ZCOS" "ZCOT" "ZCRC" "ZCSC" "ZCYC" "ZDATE" "ZDATEH" "ZDATETIME" "ZDATETIMEH" "ZDEVICE" "ZEXP" "ZF" "ZHEX" "ZINCREMENT" "ZINFO" "ZLN" "ZLOG" "ZMESSAGE" "ZNAME" "ZNEXT" "ZOBJCLASSMETHOD" "ZOBJPROPERTY" "ZORDER" "ZPARSE" "ZPOWER" "ZPREVIOUS" "ZSEARCH" "ZSEC" "ZSEEK" "ZSIN" "ZSOCKET" "ZSORT" "ZSQR" "ZSTRIP" "ZTAN" "ZTEXP" "ZTIME" "ZTIMEH" "ZTLOG" "ZTRNLMN" "ZUCI" "ascii" "bit" "bitcount" "bitfind" "bitlogic" "case" "char" "data" "extract" "factor" "find" "fnumber" "get" "increment" "inumber" "isobject" "isvalidnum" "justify" "length" "list" "listbuild" "lb" "listdata" "listfind" "listfromstring" "listget" "listlength" "listnext" "listsame" "listtostring" "name" "next" "normalize" "number" "order" "piece" "qlength" "qsubscript" "query" "random" "reverse" "select" "sortbegin" "sortend" "stack" "system" "text" "translate" "view" "zabs" "zarccos" "zarcsin" "zarctan" "zband" "zbcount" "zbfind" "zbget" "zbit" "zzbitand" "zbitcount" "zbitfind" "zbitget" "zbitlen" "zbitnot" "zbitor" "zbitset" "zbitstr" "zbitxor" "zblen" "zbnot" "zboolean" "zbor" "zbset" "zbstr" "zbxor" "zconvert" "zcvt" "zcos" "zcot" "zcrc" "zcsc" "zcyc" "zdate" "zdateh" "zdatetime" "zdatetimeh" "zdevice" "zexp" "zf" "zhex" "zincrement" "zinfo" "zln" "zlog" "zmessage" "zname" "znext" "zobjclassmethod" "zobjproperty" "zorder" "zparse" "zpower" "zprevious" "zsearch" "zsec" "zseek" "zsin" "zsocket" "zsort" "zsqr" "zstrip" "ztan" "ztexp" "ztime" "ztimeh" "ztlog" "ztrnlmn" "zuci") 92 | "MUMPS keywords for completion") 93 | 94 | ;; build the regexps from the lists 95 | (setq mumps-line-label "^[%A-Za-z][A-Za-z0-9]*:?\\|^[0-9]+:?") 96 | (setq mumps-string-error "\\\\\".*$") 97 | (setq mumps-unmatched-open-paren "\(.*$") 98 | (setq mumps-unmatched-close-paren "\).*$") 99 | (defvar mkuf (regexp-opt mumps-keywords-ucase-full 'words)) 100 | (defvar mklf (regexp-opt mumps-keywords-lcase-full 'words)) 101 | (defvar mkua (regexp-opt mumps-keywords-ucase-abbrev 'words)) 102 | (defvar mkla (regexp-opt mumps-keywords-lcase-abbrev 'words)) 103 | (defvar mfuf (regexp-opt mumps-functions-ucase-full 'words)) 104 | (defvar mflf (regexp-opt mumps-functions-lcase-full 'words)) 105 | (defvar mfua (regexp-opt mumps-functions-ucase-abbrev 'words)) 106 | (defvar mfla (regexp-opt mumps-functions-lcase-abbrev 'words)) 107 | (defvar msua (regexp-opt mumps-sv-ucase-abbrev 'words)) 108 | (defvar msla (regexp-opt mumps-sv-lcase-abbrev 'words)) 109 | (defvar msuf (regexp-opt mumps-sv-ucase-full 'words)) 110 | (defvar mslf (regexp-opt mumps-sv-lcase-full 'words)) 111 | 112 | ;; clear un-needed memory resources 113 | (setq mumps-keywords-ucase-abbrev nil) 114 | (setq mumps-keywords-ucase-full nil) 115 | (setq mumps-keywords-lcase-abbrev nil) 116 | (setq mumps-keywords-lcase-full nil) 117 | (setq mumps-functions-lcase-full nil) 118 | (setq mumps-functions-ucase-full nil) 119 | (setq mumps-functions-ucase-abbrev nil) 120 | (setq mumps-functions-lcase-abbrev nil) 121 | 122 | (setq font-lock-warning-face "red2") 123 | 124 | ;; create the thingy that we'll feed to font-lock-defaults 125 | (setq mumps-font-lock-keywords 126 | `( 127 | (,";.*$" . font-lock-comment-face) 128 | (,mkua . font-lock-keyword-face) 129 | (,mkuf . font-lock-keyword-face) 130 | (,mkla . font-lock-keyword-face) 131 | (,mklf . font-lock-keyword-face) 132 | (,msua . font-lock-keyword-face) 133 | (,msla . font-lock-keyword-face) 134 | (,msuf . font-lock-keyword-face) 135 | (,mslf . font-lock-keyword-face) 136 | (,mfuf . font-lock-function-name-face) 137 | (,mfua . font-lock-function-name-face) 138 | (,mfla . font-lock-function-name-face) 139 | (,mflf . font-lock-function-name-face) 140 | (,mumps-line-label . font-lock-type-face) 141 | (,mumps-string-error . font-lock-warning-face) 142 | )) 143 | 144 | (defun lkm-about () 145 | "About LorikeeM" 146 | (interactive) 147 | 148 | (setq lkm-about-buf "*About LorikeeM MUMPS Developer Tools*") 149 | (get-buffer-create lkm-about-buf) 150 | (with-current-buffer (get-buffer-create lkm-about-buf) 151 | (goto-char (point-max)) 152 | (insert "LorikeeM MUMPS Developer Tools\n\n")) 153 | (switch-to-buffer-other-window lkm-about-buf)) 154 | 155 | (defun lkm-gtm-compile () 156 | "Compiles the current buffer" 157 | (interactive) 158 | 159 | (setq file-name (buffer-file-name)) 160 | (setq cmd-str (concat "mumps " file-name)) 161 | (compile cmd-str nil)) 162 | 163 | (defun lkm-global-at-point () 164 | "Look up the GT.M/YottaDB global at the word under the current point." 165 | 166 | (interactive) 167 | (let (mm-current-word) 168 | (setq current-char (char-to-string (char-after))) 169 | (if (string= current-char "^") (forward-char 1)) 170 | (setq mm-current-word (thing-at-point 'word)) 171 | (save-excursion 172 | (setq prev-char (char-to-string (char-before))) 173 | (if (not (string= prev-char "^")) (backward-word 1)) 174 | (setq prev-char (char-to-string (char-before))) 175 | (if (string= prev-char "^") 176 | (lkm-gtm-global-lookup mm-current-word) 177 | (message "%s does not appear to be a MUMPS global." mm-current-word))))) 178 | 179 | (defun lkm-is-line-label () 180 | "Returns t if the current line is a label" 181 | (setq current-line (thing-at-point 'line)) 182 | (string-match "^[%A-Za-z][A-Za-z0-9]*:?\\|^[0-9]+:?" current-line)) 183 | 184 | (defun lkm-validate-line-label () 185 | "Tells you whether or not the current line contains a valid line label" 186 | (interactive) 187 | (if (lkm-is-line-label) 188 | (message "This is a line label")) 189 | (if (not (lkm-is-line-label)) 190 | (message "This is not a line label"))) 191 | 192 | (defun lkm-parent-label-distance () 193 | "Returns the distance from the parent label in number of lines" 194 | (setq lkm-distance 0) 195 | (save-excursion 196 | (catch 'top-of-file 197 | (while (not (lkm-is-line-label)) 198 | (if (= (line-number-at-pos) 1) 199 | (throw 'top-of-file lkm-distance)) 200 | (forward-line -1) 201 | (incf lkm-distance)))) 202 | (setq lkm-distance lkm-distance)) 203 | 204 | (defun lkm-print-parent-label-distance () 205 | "Print the distance from the parent label" 206 | (interactive) 207 | (message "The distance from the parent label is %d lines" (lkm-parent-label-distance))) 208 | 209 | (defun lkm-parent-label-name () 210 | "Returns the name of the parent label" 211 | (save-excursion 212 | (forward-line (- (lkm-parent-label-distance))) 213 | (setq label-line (thing-at-point 'line))) 214 | (string-match "^[%A-Za-z][A-Za-z0-9]*:?\\|^[0-9]+:?" label-line) 215 | (setq label-line (substring label-line 0 (match-end 0))) 216 | (replace-regexp-in-string "%" "%%" label-line)) 217 | 218 | (defun lkm-print-parent-label-name () 219 | "Print the parent label name" 220 | (interactive) 221 | (message "The parent label is '%s'" (lkm-parent-label-name))) 222 | 223 | (defun lkm-current-routine () 224 | "Get the current routine" 225 | (setq pl-routine (file-name-sans-extension (buffer-name))) 226 | (setq pl-routine (replace-regexp-in-string "_" "%%" pl-routine))) 227 | 228 | (defun lkm-print-current-routine () 229 | "Print the current routine" 230 | (interactive) 231 | (message "The current routine is '%s'" (lkm-current-routine))) 232 | 233 | (defun lkm-current-label-offset-routine () 234 | "Get the current label+offset^routine" 235 | (setq pl-label (lkm-parent-label-name)) 236 | (setq pl-offset (lkm-parent-label-distance)) 237 | (setq pl-routine (lkm-current-routine)) 238 | (if (not (= pl-offset 0)) 239 | (setq pl-result (format "%s+%d^%s" pl-label pl-offset pl-routine))) 240 | (if (= pl-offset 0) 241 | (setq pl-result (format "%s^%s" pl-label pl-routine))) 242 | (setq pl-result pl-result)) 243 | 244 | (defun lkm-print-current-label-offset-routine () 245 | "Print the current label+offset^routine" 246 | (interactive) 247 | (message (lkm-current-label-offset-routine))) 248 | 249 | (defun lkm-gtm-global-lookup (global) 250 | "Look up a global in GT.M/YottaDB" 251 | (interactive "sWhat global would you like to look up? ") 252 | 253 | (get-buffer-create "*MUMPS Global Examiner*") 254 | (with-current-buffer (get-buffer-create "*MUMPS Global Examiner*") 255 | (goto-char (point-max)) 256 | (insert "MUMPS Global Dump of " global "\n\n")) 257 | (call-process "mumps" nil "*MUMPS Global Examiner*" nil "-r" "KBAWDUMP" global) 258 | (display-buffer (get-buffer "*MUMPS Global Examiner*") t) 259 | (with-current-buffer (get-buffer-create "*MUMPS Global Examiner*") 260 | (goto-char (point-max)))) 261 | 262 | (defun lkm-jump-to-routine-def () 263 | "Jump to the definition of the routine under the cursor." 264 | (interactive) 265 | (setq lkm-current-symb (thing-at-point 'symbol)) 266 | (find-tag-other-window lkm-current-symb)) 267 | 268 | (defun yas/insert-by-name (name) 269 | (flet ((dummy-prompt 270 | (prompt choices &optional display-fn) 271 | (declare (ignore prompt)) 272 | (or (find name choices :key display-fn :test #'string=) 273 | (throw 'notfound nil)))) 274 | (let ((yas/prompt-functions '(dummy-prompt))) 275 | (catch 'notfound 276 | (yas/insert-snippet t))))) 277 | 278 | (defun lkm-routine-template () 279 | "Get the template of the routine under the cursor." 280 | (interactive) 281 | (setq lkm-current-symb (thing-at-point 'symbol)) 282 | (insert "()") 283 | (backward-char 1) 284 | (yas/insert-by-name lkm-current-symb)) 285 | 286 | (defun lkm-expand-quote () 287 | "Set up a string literal." 288 | (interactive) 289 | (insert "\"\"") 290 | (backward-char 1)) 291 | 292 | (defun lkm-sac-header () 293 | "Insert the standard VistA SAC header" 294 | (interactive) 295 | (goto-char (point-min)) 296 | (yas/insert-by-name "SACHEADER")) 297 | 298 | (defun lkm-complete-symbol () 299 | "Perform keyword completion on word before cursor." 300 | (interactive) 301 | (let ((posEnd (point)) 302 | (meat (thing-at-point 'symbol)) 303 | maxMatchResult) 304 | 305 | ;; when nil, set it to empty string, so user can see all lang's keywords. 306 | ;; if not done, try-completion on nil result lisp error. 307 | (when (not meat) (setq meat "")) 308 | (setq maxMatchResult (try-completion meat mumps-keywords)) 309 | 310 | (cond ((eq maxMatchResult t)) 311 | ((null maxMatchResult) 312 | (message "Can't find completion for “%s”" meat) 313 | (ding)) 314 | ((not (string= meat maxMatchResult)) 315 | (delete-region (- posEnd (length meat)) posEnd) 316 | (insert maxMatchResult)) 317 | (t (message "Making completion list...") 318 | (with-output-to-temp-buffer "*Completions*" 319 | (display-completion-list 320 | (all-completions meat mumps-keywords) 321 | meat)) 322 | (message "Making completion list...%s" "done"))))) 323 | 324 | 325 | (defun lkm-start-debugger () 326 | "Begins the default GT.M/YottaDB child process for debugging" 327 | (interactive) 328 | (setq lkm-debug-window (split-window nil 20)) 329 | (get-buffer-create "Debug") 330 | (set-window-buffer lkm-debug-window "Debug") 331 | (setq buffer-saved (current-buffer)) 332 | (set-buffer "Debug") 333 | (setq buffer-read-only t) 334 | (set-buffer buffer-saved) 335 | (setq gtm-dist (getenv "gtm_dist")) 336 | (setq mcmd (format "%s%s" gtm-dist "/mumps")) 337 | (start-process "debugger" "Debug" mcmd "-r" "^KBBMDBUG")) 338 | 339 | (defun lkm-stop-debugger () 340 | "Stops the debugger" 341 | (interactive) 342 | (setq debug-string "HALT\n") 343 | (process-send-string "debugger" debug-string)) 344 | 345 | (defun lkm-interrupt-debugger () 346 | "Interrupts the running process" 347 | (interactive) 348 | (interrupt-process "debugger")) 349 | 350 | (defun lkm-resume-debugger () 351 | (interactive) 352 | (setq debug-string "ZCONTINUE\n") 353 | (process-send-string "debugger" debug-string)) 354 | 355 | (defun lkm-debug-routine () 356 | "Begins debug at current routine" 357 | (interactive) 358 | (setq debug-string (format "DO %s^%s\n" (lkm-parent-label-name) (lkm-current-routine))) 359 | (process-send-string "debugger" debug-string)) 360 | 361 | (defun lkm-set-breakpoint () 362 | "Sets a breakpoint at the current line" 363 | (interactive) 364 | (setq debug-string (format "ZBREAK %s\n" (lkm-current-label-offset-routine))) 365 | (process-send-string "debugger" debug-string)) 366 | 367 | (defun lkm-clear-breakpoint () 368 | "Clears a breakpoint at the current line" 369 | (interactive) 370 | (setq debug-string (format "ZBREAK -%s\n" (lkm-current-label-offset-routine))) 371 | (process-send-string "debugger" debug-string)) 372 | 373 | (defun lkm-clear-all-breakpoints () 374 | "Clears all breakpoints" 375 | (interactive) 376 | (setq debug-string (format "ZBREAK -*\n" (lkm-current-label-offset-routine))) 377 | (process-send-string "debugger" debug-string)) 378 | 379 | (defun lkm-list-breakpoints () 380 | "Lists all breakpoints" 381 | (interactive) 382 | (setq debug-string "ZSHOW \"B\"\n") 383 | (process-send-string "debugger" debug-string)) 384 | 385 | (defun lkm-step-into () 386 | "Executes ZSTEP INTO" 387 | (interactive) 388 | (setq debug-string "ZSTEP INTO\n") 389 | (process-send-string "debugger" debug-string)) 390 | 391 | (defun lkm-step-over () 392 | "Executes ZSTEP OVER" 393 | (interactive) 394 | (setq debug-string "ZSTEP OVER\n") 395 | (process-send-string "debugger" debug-string)) 396 | 397 | (defun lkm-step-out () 398 | "Executes ZSTEP OUT" 399 | (interactive) 400 | (setq debug-string "ZSTEP OUT\n") 401 | (process-send-string "debugger" debug-string)) 402 | 403 | (defun lkm-immediate (value) 404 | "Executes a line of MUMPS code or sends input to a pending MUMPS READ" 405 | (interactive "sEnter MUMPS command or input for pending READ: ") 406 | (setq debug-string (format "%s\n" value)) 407 | (process-send-string "debugger" debug-string)) 408 | 409 | (define-derived-mode mumps-mode fundamental-mode 410 | "mumps mode" 411 | "LorikeeM MUMPS Developer Tools" 412 | 413 | (setq lkm-version "0.99.8") 414 | (message "LorikeeM MUMPS Developer Tools %s" lkm-version) 415 | 416 | (add-hook 'shell-mode-hook 417 | 'ansi-color-for-comint-mode-on) 418 | 419 | (setq frame-title-format "LorikeeM MUMPS Developer Tools") 420 | 421 | (set-variable 422 | 'imenu-generic-expression 423 | (list 424 | (list 425 | nil 426 | "\\(^[%A-Za-z][A-Za-z0-9]*\\):?\\|^[0-9]+:?" 1))) 427 | (imenu-add-to-menubar "Labels") 428 | 429 | (setq mode-line-format 430 | (list 431 | " " 432 | '(:eval (propertize (lkm-current-label-offset-routine) 'face 'font-lock-string-face 433 | 'help-echo "Help")) 434 | " " 435 | 436 | ;; relative position, size of file 437 | "[" 438 | (propertize "%p" 'face 'font-lock-constant-face) ;; % above top 439 | "/" 440 | (propertize "%I" 'face 'font-lock-constant-face) ;; size 441 | "] [" 442 | (propertize "Line %l Col %c" 'face 'font-lock-constant-face) 443 | "] " 444 | 445 | "[" ;; insert vs overwrite mode, input-method in a tooltip 446 | '(:eval (propertize (if overwrite-mode "Ovr" "Ins") 447 | 'face 'font-lock-preprocessor-face 448 | 'help-echo (concat "Buffer is in " 449 | (if overwrite-mode "overwrite" "insert") " mode"))) 450 | 451 | ;; was this buffer modified since the last save? 452 | '(:eval (when (buffer-modified-p) 453 | (concat "," (propertize "Mod" 454 | 'face 'font-lock-warning-face 455 | 'help-echo "Buffer has been modified")))) 456 | 457 | ;; is this buffer read-only? 458 | '(:eval (when buffer-read-only 459 | (concat "," (propertize "RO" 460 | 'face 'font-lock-type-face 461 | 'help-echo "Buffer is read-only")))) 462 | "] " 463 | 464 | )) 465 | 466 | ;; 467 | ;; set up syntax table entries 468 | ;; 469 | 470 | ;; syntax table entries for symbol constituents 471 | ;; we're adding ^ and % to accommodate MUMPS routine calls 472 | (modify-syntax-entry ?^ "_") 473 | (modify-syntax-entry ?% "_") 474 | (modify-syntax-entry ?$ "-") 475 | (modify-syntax-entry ?\; "<") 476 | (modify-syntax-entry ?\n ">") 477 | (modify-syntax-entry ?+ ".") 478 | (modify-syntax-entry ?- ".") 479 | (modify-syntax-entry ?_ ".") 480 | (modify-syntax-entry ?[ ".") 481 | (modify-syntax-entry ?* ".") 482 | (modify-syntax-entry ?/ ".") 483 | (modify-syntax-entry ?\\ ".") 484 | (modify-syntax-entry ?# ".") 485 | (modify-syntax-entry ?< ".") 486 | (modify-syntax-entry ?> ".") 487 | (modify-syntax-entry ?& ".") 488 | (modify-syntax-entry ?? ".") 489 | 490 | ;; 491 | ;; modify the tags table list to point to our directory 492 | ;; 493 | (setq tags-file-name "~/.MTAGS") 494 | 495 | ;; 496 | ;; set up keyboard mappings 497 | ;; 498 | (global-set-key (kbd "") 'lkm-global-at-point) 499 | (global-set-key (kbd "") 'lkm-gtm-global-lookup) 500 | (global-set-key (kbd "") 'lkm-jump-to-routine-def) 501 | (global-set-key (kbd "") 'lkm-debug-routine) 502 | (global-set-key (kbd "") 'lkm-gtm-compile) 503 | (global-set-key (kbd "(") 'lkm-routine-template) 504 | (global-set-key (kbd "\"") 'lkm-expand-quote) 505 | 506 | ;; 507 | ;; set up the LorikeeM menus to be loaded after the Tools menu 508 | ;; 509 | (define-key-after 510 | global-map 511 | [menu-bar vista-menu] 512 | (cons "VistA" (make-sparse-keymap "vista")) 513 | 'tools ) 514 | 515 | (define-key-after 516 | global-map 517 | [menu-bar globals-menu] 518 | (cons "Globals" (make-sparse-keymap "globals")) 519 | 'tools ) 520 | 521 | (define-key-after 522 | global-map 523 | [menu-bar routines-menu] 524 | (cons "Routines" (make-sparse-keymap "routines")) 525 | 'tools ) 526 | 527 | (define-key-after 528 | global-map 529 | [menu-bar debug-menu] 530 | (cons "Debug" (make-sparse-keymap "debug")) 531 | 'tools ) 532 | 533 | (define-key-after 534 | global-map 535 | [menu-bar mumps-menu] 536 | (cons "MUMPS" (make-sparse-keymap "mumps")) 537 | 'tools ) 538 | 539 | (define-key 540 | global-map 541 | [menu-bar debug-menu send-input] 542 | '("Immediate" . lkm-immediate)) 543 | 544 | (define-key 545 | global-map 546 | [menu-bar debug-menu step-over] 547 | '("Step Over" . lkm-step-over)) 548 | 549 | (define-key 550 | global-map 551 | [menu-bar debug-menu step-out] 552 | '("Step Out" . lkm-step-out)) 553 | 554 | (define-key 555 | global-map 556 | [menu-bar debug-menu step-into] 557 | '("Step Into" . lkm-step-into)) 558 | 559 | (define-key 560 | global-map 561 | [menu-bar debug-menu list-breakpoints] 562 | '("List Breakpoints" . lkm-list-breakpoints)) 563 | 564 | (define-key 565 | global-map 566 | [menu-bar debug-menu clear-all-breakpoints] 567 | '("Clear All Breakpoints" . lkm-clear-all-breakpoints)) 568 | 569 | (define-key 570 | global-map 571 | [menu-bar debug-menu clear-breakpoint] 572 | '("Clear Breakpoint" . lkm-clear-breakpoint)) 573 | 574 | (define-key 575 | global-map 576 | [menu-bar debug-menu set-breakpoint] 577 | '("Set Breakpoint" . lkm-set-breakpoint)) 578 | 579 | (define-key 580 | global-map 581 | [menu-bar debug-menu resume-debugger] 582 | '("Resume" . lkm-resume-debugger)) 583 | 584 | (define-key 585 | global-map 586 | [menu-bar debug-menu break-debugger] 587 | '("Break" . lkm-interrupt-debugger)) 588 | 589 | (define-key 590 | global-map 591 | [menu-bar debug-menu debug-routine] 592 | '("Debug Current Routine" . lkm-debug-routine)) 593 | 594 | (define-key 595 | global-map 596 | [menu-bar debug-menu stop-debugger] 597 | '("Stop Debugger" . lkm-stop-debugger)) 598 | 599 | (define-key 600 | global-map 601 | [menu-bar debug-menu start-debugger] 602 | '("Start Debugger" . lkm-start-debugger)) 603 | 604 | (define-key 605 | global-map 606 | [menu-bar globals-menu gli] 607 | '("Examine" . lkm-gtm-global-lookup)) 608 | (define-key 609 | global-map 610 | [menu-bar globals-menu gls] 611 | '("Examine at Cursor" . lkm-global-at-point)) 612 | 613 | (define-key 614 | global-map 615 | [menu-bar vista-menu sachdr] 616 | '("Insert VistA SAC Header" . lkm-sac-header)) 617 | 618 | (define-key 619 | global-map 620 | [menu-bar routines-menu jmp] 621 | '("Find Routine" . lkm-jump-to-routine-def)) 622 | (define-key 623 | global-map 624 | [menu-bar mumps-menu cmp] 625 | '("Complete Keyword at Cursor" . lkm-complete-symbol)) 626 | (define-key 627 | global-map 628 | [menu-bar mumps-menu com] 629 | '("Compile Current Buffer" . lkm-gtm-compile)) 630 | 631 | (setq font-lock-defaults '((mumps-font-lock-keywords))) 632 | 633 | (setq mkua nil) 634 | (setq mkuf nil) 635 | (setq mkla nil) 636 | (setq mklf nil) 637 | (setq mfua nil) 638 | (setq mfuf nil) 639 | (setq mfla nil) 640 | (setq mflf nil) 641 | (setq mo nil) 642 | 643 | (setq mode-name "LorikeeM MUMPS Developer Tools") 644 | ;(lkm-start-debugger) 645 | (run-hooks 'mumps-mode-hook) 646 | ) 647 | -------------------------------------------------------------------------------- /src/mumps/KBAWDUMP.m: -------------------------------------------------------------------------------- 1 | KBAWDUMP ;FWSLC/DLW-Dump a global on the command line; 10/21/12 1:49pm 2 | ;;0.20.3;Axiom;****LOCAL RTN**;David Wicksell @2010-2012 3 | ; 4 | ; Written by David Wicksell 5 | ; Copyright © 2010,2011 Fourth Watch Software, LC 6 | ; 7 | ; This program is free software: you can redistribute it and/or modify 8 | ; it under the terms of the GNU Affero General Public License (AGPL) 9 | ; as published by the Free Software Foundation, either version 3 of 10 | ; the License, or (at your option) any later version. 11 | ; 12 | ; This program is distributed in the hope that it will be useful, 13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ; GNU Affero General Public License for more details. 16 | ; 17 | ; You should have received a copy of the GNU Affero General Public License 18 | ; along with this program. If not, see http://www.gnu.org/licenses/. 19 | ; 20 | ; This routine was created for GT.M in a Unix environment. 21 | ; 22 | ; This routine will dump the contents of a MUMPS global 23 | ; from a shell prompt. It is invoked as a mumps -run 24 | ; command. E.g. mumps -r KBAWDUMP '^DD(0,0)' 25 | ; 26 | ; The single quotes around the global name are required. 27 | ; If you don't use them, then most shells (BASH for sure) 28 | ; will think you are trying to start a subshell with the 29 | ; parens. The "^" is optional, and putting a "-" as the first 30 | ; character, will dump only the node referenced, otherwise 31 | ; it will be assumed that you want that node and every one 32 | ; of its children. 33 | ; 34 | ; Added ability to deal with local variables, by dumping 35 | ; every option in the global that the local variable could 36 | ; represent. 37 | ; 38 | ; Added the GLOBALS entry point, to simulate calling ^%GD 39 | ; from a shell. Also added the ability to specify a range. 40 | ; 41 | ; If your screen becomes messed up after piping this 42 | ; program to less, it probably means that "te" is not set 43 | ; to reset the terminal to the settings that were present 44 | ; when "ti" was called. GT.M may not be user friendly in 45 | ; this regard, though I haven't really dug into the issue. 46 | ; If you don't plan on doing your own custom terminal 47 | ; handling, a quick solution would be to create an alias 48 | ; for less to put your screen back to "sane" settings 49 | ; while using it. I.e. $ alias less='less;stty sane' 50 | ; 51 | ; 52 | N $ET S $ET="G ERR" 53 | ; 54 | N ZCMD,VIM S ZCMD=$ZCMD,VIM=0 55 | I $E(ZCMD)="-" S ZCMD=$E(ZCMD,2,$L(ZCMD)),VIM=1 ;set VIM mode (no children) 56 | ; 57 | N ARGS S ARGS=$L(ZCMD," ") 58 | I 'VIM,ARGS'=1!(ZCMD="") D Q ;normal argument handling 59 | . W "KBAWDUMP takes one argument, the global reference.",! 60 | ; 61 | I $E(ZCMD)'="^" S ZCMD="^"_ZCMD ;supply the ^, if not specified 62 | ; 63 | N GLOBAL 64 | I ZCMD["(" D ;if you have subscripts, you need to isolate the contents 65 | . S GLOBAL=$P(ZCMD,"(")_"(" 66 | . N CNT S CNT=$L(ZCMD,"(") ;handle multiple parens 67 | . N ARG S ARG=$P(ZCMD,"(",2,CNT),ARG=$E(ARG,1,$L(ARG)-1) 68 | . ; 69 | . N I,FLG,NUM,DONE S FLG=0,NUM=$L(ARG,",") 70 | . F I=1:1:NUM D 71 | . . S DONE=0 72 | . . S ARG(I)=$P(ARG,",",I) 73 | . . S:$L(ARG(I),"""")=2 FLG=1-FLG ;deal with "," in strings 74 | . . ; 75 | . . I $L(ARG(I),"""")=1,$E(ARG(I))'?1(1N,1".",1"-") D ;local variables 76 | . . . Q:FLG ;avoid a ",name," in a string being treated like a variable 77 | . . . S:VIM VIM=2 78 | . . . S:ARG(I)'="*" ARG(I)=":" ;subscript wildcard 79 | . . ; 80 | . . I $L(ARG(I),"""")=3&(ARG(I)["""_"!(ARG(I)["_""")) D ;a string and variable 81 | . . . S:VIM VIM=2 82 | . . . S:ARG(I)'="*" ARG(I)=":" ;subscript wildcard 83 | . . S:ARG(I)="""""" ARG(I)="*" ;special case of "" used as a subscript for $O 84 | . . ; 85 | . . I $E(ARG(I),2)="""" D ;deal with strings inside XECUTE strings 86 | . . . N DIV 87 | . . . F DIV=1:1:$L(ARG(I)) Q:$E(ARG(I),DIV)'="""" 88 | . . . S DIV=DIV-1 89 | . . . ; 90 | . . . N J,SCNT,NARG,FILL S SCNT=0,NARG="" 91 | . . . F J=1:1:$L(ARG(I)) D 92 | . . . . I $E(ARG(I),J)="""" S SCNT=SCNT+1 93 | . . . . E D 94 | . . . . . S:SCNT $P(FILL,"""",SCNT/DIV+1)="",SCNT=0 ;put right amount of quotes 95 | . . . . . S NARG=NARG_FILL_$E(ARG(I),J),FILL="" ;build the argument back up 96 | . . . . ; 97 | . . . . I $L(ARG(I))=J D ;put right amount of ending quotes 98 | . . . . . S $P(FILL,"""",SCNT/DIV+1)="" 99 | . . . . . S NARG=NARG_FILL 100 | . . . S GLOBAL=GLOBAL_NARG_"," ;rebuild the args 101 | . . . S DONE=1 ;set DONE to indicate args already built 102 | . . I $E(ARG(I),1)'=""""&((ARG(I)["(")!(ARG(I)[")")) D ;complex subscripts 103 | . . . S ARG(I)=":" ;should catch most functions and variables with subscripts 104 | . . S:'DONE GLOBAL=GLOBAL_ARG(I)_"," ;rebuild the args 105 | . S GLOBAL=$E(GLOBAL,1,$L(GLOBAL)-1) ;get rid of the last comma 106 | . I $E(GLOBAL,$L(GLOBAL))'=")" D ;some indirection strings get complicated 107 | . . I VIM S GLOBAL=GLOBAL_")" ;add the last ) back without the ,* in VIM mode 108 | . . E S GLOBAL=GLOBAL_",*)" ;add the last ) back with the ,* from the shell 109 | ;deal with extra spaces at the end of the :ZWR command or a quoted argument 110 | E S GLOBAL=$E(ZCMD,1,$S(ZCMD[" ":$F(ZCMD," ")-2,1:$L(ZCMD))) ;no subscripts 111 | ;ZWR command with no subscripts, postcondition stops WRITE if undefined 112 | I VIM=1,GLOBAL'["(" W:$D(@GLOBAL)#2 GLOBAL_"="_@GLOBAL,! 113 | E ZWR @GLOBAL 114 | Q 115 | ; 116 | GLOBALS ;List all the globals to standard out, a simpler version of ^%GD 117 | ; 118 | ; You can provide no arguments and it will list every global 119 | ; in the database. Or you can supply a range of global names, 120 | ; and it will list every global between the range, inclusive. 121 | ; You specify the range with a colon and if the colon is the 122 | ; first character, it will list all the globals from the 123 | ; beginning of the database to the global listed after the 124 | ; colon, and if there is nothing after the colon it will list 125 | ; every global from the global before the colon to the end of 126 | ; the database. 127 | ; 128 | ; E.g. mumps -r GLOBALS^KBAWDUMP A:Z 129 | ; E.g. mumps -r GLOBALS^KBAWDUMP :z 130 | ; E.g. mumps -r GLOBALS^KBAWDUMP a: 131 | ; 132 | ; A colon by itself will also list every global, same as no 133 | ; arguments. It is important that you have no spaces between 134 | ; the global names and the colon, it must be one argument on 135 | ; the command line. 136 | ; 137 | N $ET S $ET="G ERR" 138 | ; 139 | N ZCMD,ARGS S ZCMD=$ZCMD,ARGS=$L(ZCMD," ") 140 | ; 141 | I ARGS>1 D Q ;normal argument handling 142 | . W "GLOBALS^KBAWDUMP takes one argument, the range of the globals to list,",! 143 | . W "or no arguments and will list every global in the database.",! 144 | ; 145 | ;if given, parse range on the : (ignore multiple colons) 146 | N GLOBAL,END 147 | I ZCMD]"" S GLOBAL="^"_$P(ZCMD,":"),END="^"_$P(ZCMD,":",2) 148 | E S GLOBAL="^%",END="" ;% sorts first in default ascii 149 | ; 150 | S:GLOBAL="^" GLOBAL="^%" S:END="^" END="" 151 | S:$E(GLOBAL,1,2)="^^" GLOBAL=$E(GLOBAL,2,$L(GLOBAL)) 152 | S:$E(END,1,2)="^^" END=$E(END,2,$L(END)) 153 | ; 154 | W:$D(@GLOBAL) GLOBAL,! ;need to print the initial global 155 | ; 156 | F S GLOBAL=$O(@GLOBAL) Q:GLOBAL=""!(GLOBAL]]END&(END]"")) W GLOBAL,! 157 | Q 158 | ; 159 | ERR ;Handle globals that don't exist 160 | N $ET S $ET="H" 161 | W $P($ZS," ",2,$L($ZS," ")),! 162 | Q 163 | -------------------------------------------------------------------------------- /src/mumps/KBBMDBUG.m: -------------------------------------------------------------------------------- 1 | KBBMDBUG 2 | w "LorikeeM Interactive Debugger",! 3 | w " Copyright (C) 2013 Coherent Logic Development LLC",!,! 4 | w "Debugger is ready (Job ID ",$J,")",! 5 | s $zint="w ""Break at ""_$zpos d ^KBBMDBUG" 6 | s $zprompt="DEBUG> " 7 | f i=0:0 u 0 r code w ! x code 8 | q 9 | -------------------------------------------------------------------------------- /src/mumps/KBBMLRKM.m: -------------------------------------------------------------------------------- 1 | KBBMLRKM ; LorikeeM runtime library 2 | n cmdLine,oper,param 3 | s cmdLine=$zcmd 4 | s oper=$P(cmdLine,"~",1) 5 | s param=$P(cmdLine,"~",2) 6 | i oper="EXTRINSIC" d extrinsic(param) 7 | i oper="ROUTINE" d routine(param) 8 | i oper="DEBUG" d debugger 9 | q 10 | 11 | extrinsic(parm) 12 | n execStr s execStr="W $$"_parm_",!" 13 | x execStr 14 | q 15 | 16 | routine(parm) 17 | n execStr s execStr="D "_parm 18 | x execStr 19 | q 20 | 21 | debugger 22 | w "LorikeeM Interactive Debugger",! 23 | w " Copyright (C) 2013 Coherent Logic Development LLC",!,! 24 | w "Debugger is ready.",! 25 | f i=0:0 u 0 r code x code 26 | q 27 | -------------------------------------------------------------------------------- /src/yasnippet/.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | sudo: false 3 | git: 4 | submodules: false 5 | 6 | env: 7 | global: 8 | - Wlexical=t 9 | - Werror=t 10 | - tests_Werror=t # For yasnippet-tests.el 11 | matrix: 12 | - EMACS_VERSION=23.4 13 | # 24.3 gives a bunch of 'value returned from (car value-N) is 14 | # unused' warnings. 15 | - EMACS_VERSION=24.3 tests_Werror=nil 16 | - EMACS_VERSION=24.5 17 | - EMACS_VERSION=25.3 18 | - EMACS_VERSION=26-prerelease 19 | 20 | 21 | install: 22 | - curl -LO https://github.com/npostavs/emacs-travis/releases/download/bins/emacs-bin-${EMACS_VERSION}.tar.gz 23 | - tar -xaf emacs-bin-${EMACS_VERSION}.tar.gz -C / 24 | # Configure $PATH: Emacs installed to /tmp/emacs 25 | - export PATH=/tmp/emacs/bin:${PATH} 26 | - if ! emacs -Q --batch --eval "(require 'cl-lib)" ; then 27 | curl -Lo cl-lib.el http://elpa.gnu.org/packages/cl-lib-0.6.1.el ; 28 | export warnings="'(not cl-functions)" ; 29 | fi 30 | - if ! emacs -Q --batch --eval "(require 'ert)" ; then 31 | curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert.el && 32 | curl -LO https://raw.githubusercontent.com/ohler/ert/c619b56c5bc6a866e33787489545b87d79973205/lisp/emacs-lisp/ert-x.el ; 33 | fi 34 | - emacs --version 35 | 36 | script: 37 | - rake yasnippet.elc 38 | - rake yasnippet-debug.elc 39 | - rake yasnippet-tests.elc Werror=$tests_Werror 40 | - rake tests 41 | 42 | notifications: 43 | email: 44 | # Default is change, but that includes a new branch's 1st success. 45 | on_success: never 46 | on_failure: always # The default. 47 | -------------------------------------------------------------------------------- /src/yasnippet/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Submitting Bug Reports or Patches 2 | 3 | As a GNU ELPA package, bugs or patches may be submitted to the main 4 | Emacs bug list, bug-gnu-emacs@gnu.org. Alternatively, you may use the 5 | [Github issue tracker][issues]. 6 | 7 | Please read [Important note regarding bug reporting][bugnote]. 8 | 9 | # Contributing to Yasnippet 10 | 11 | ## Copyright Assignment 12 | 13 | Yasnippet is part of GNU ELPA, so it falls under the same copyright 14 | assignment policy as the rest of Emacs (see "Copyright Assignment" in 15 | https://www.gnu.org/software/emacs/CONTRIBUTE). A copyright assignment 16 | for Emacs also covers Yasnippet. 17 | 18 | ## Commit message format 19 | 20 | The commit message format roughly follows Emacs conventions. There is 21 | no separate Changelog file. 22 | 23 | Capitalize the first sentence, no period at the end 24 | 25 | Please make sure the summary line can be understood without having 26 | to lookup bug numbers. It may be followed by a paragraph with a 27 | longer explanation. The changelog style entry goes at the end of 28 | the message. 29 | * foo.el (a-function): Terse summary of per-function changes. Use 30 | double spacing between sentences (set `sentence-end-double-space' 31 | to t). 32 | 33 | For trivial changes, a message consisting of just the changelog entry 34 | (e.g., `* foo.el (a-function): Fix docstring typo.`) is fine. 35 | 36 | [bugnote]: https://github.com/joaotavora/yasnippet#important-note-regarding-bug-reporting 37 | [issues]: https://github.com/joaotavora/yasnippet/issues 38 | -------------------------------------------------------------------------------- /src/yasnippet/NEWS: -------------------------------------------------------------------------------- 1 | Yasnippet NEWS -- history of user-visible changes. 2 | 3 | Copyright (C) 2017 Free Software Foundation, Inc. 4 | See the end of the file for license conditions. 5 | 6 | * 0.12.2 (Aug 28, 2017) 7 | 8 | ** The new option 'yas-also-auto-indent-empty-lines' allows restoring 9 | the old indent behavior. See Github #850, #710, #685, #679. 10 | 11 | ** Keybinding triggered snippets once again deactivate the mark. 12 | See Github #840. 13 | 14 | 15 | * 0.12.1 (Jul 23, 2017) 16 | 17 | This is a quick bugfix release. 18 | 19 | ** Compilation errors in yasnippet-tests.el and yasnippet-debug.el are fixed. 20 | 21 | ** A snippet-local setting of 'yas-indent-line' is now respected 22 | during indentation triggered by auto-fill as well. See Github #838. 23 | 24 | 25 | * 0.12.0 (Jul 17, 2017) 26 | 27 | ** Changes and New Features 28 | 29 | *** Snippets can now expand in strings & comments by default again. 30 | 'yas-buffer-local-condition' is now a defcustom See Github #774. 31 | 32 | *** 'yas-after-exit-snippet-hook' can now be bound in 'expand-env' of 33 | snippets. See Github #28, #702, #779, #786. 34 | 35 | *** Snippets under directories in 'yas-snippet-dirs' are now in 36 | snippet-mode automatically. 37 | 38 | *** Snippets can now be expanded in org source blocks, if 39 | 'org-src-tab-acts-natively' and 'org-src-fontify-natively' are set. 40 | See Github #761. 41 | 42 | *** 'yas-fallback-behavior' is now obsolete, 'yas-expand' is now bound 43 | conditionally with an extended menu item, 'yas-maybe-expand'. 44 | Therefore users wanting to bind 'yas-expand' to a different key, SPC 45 | for example, should do 46 | 47 | (define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand) 48 | 49 | See Github #760, #808. 50 | 51 | *** The documentation build output is now reproducible. The timestamp 52 | now depends on the commit date, or the environment variable 53 | SOURCE_DATE_EPOCH is that is set. 54 | 55 | *** 'yas-indent-line' and 'expand-env' are now respected during mirror 56 | updates. See Github #743. 57 | 58 | *** New function 'yas-active-snippets'. Renamed from 59 | 'yas--snippets-at-point', which remains as an obsolete alias. See 60 | Github #727. 61 | 62 | *** New custom option 'yas-overlay-priority'. This is can be used to 63 | give the snippet navigation keymaps higher priority than keymaps from 64 | overlays created by other packages, like 'auto-complete'. See Github 65 | #828. 66 | 67 | ** Fixed bugs 68 | 69 | *** Snippets having ${0:soon-to-be-deleted} with no other fields now 70 | correctly put the field 0 text in the active region after exiting. 71 | See Github #653. 72 | 73 | *** Fix undo of snippet insertion which also triggers indentation. 74 | See Github #821. 75 | 76 | *** Fixed a bug causing whitespace loss between mirrors. 77 | 78 | *** Fixed several bugs causing problems when combining Yasnippet with 79 | other modes and packages, like 'auto-fill-mode', 'c++-mode', 80 | 'rust-mode', and 'lentic'. 81 | 82 | **** Fix another bug with auto-fill-mode. 83 | See Github #784, #794. 84 | 85 | **** Fix a bug in parsing of snippet fields for modes that use the 86 | 'syntax-table' text property, 'c++-mode' is one example of this. See 87 | Github #815. 88 | 89 | **** 'syntax-propertize-function' is now restored before indenting the 90 | snippet. This improves compatibility with modes which rely on it for 91 | indentation, like 'rust-mode'. See Github #782, #818. 92 | 93 | **** Avoid trying to delete a snippet which is already deleted. This 94 | prevents an error when using 'rust-mode's 'rust-format-buffer' 95 | command. 96 | 97 | **** Ensure inhibit-modification-hooks is nil while modifying buffer. 98 | This fixes problems for packages relying on modification hooks, like 99 | 'lentic'. See Github #756, #712. 100 | 101 | 102 | * 0.11.0 (Oct 26, 2016) 103 | ** Changes and New Features 104 | 105 | *** Modifying buffer in backquoted expressions is deprecated! 106 | Backquoted expressions should only return a string that will be 107 | inserted. Snippets which modify the buffer as a side-effect will now 108 | trigger a warning. 109 | 110 | *** The verbosity levels for messages have been adjusted. 111 | While the default verbosity level was increased by 1 (it was only 112 | lower before due to a bug), several messages now only print at the 113 | level 4, so the overall effect should be less messages by default. 114 | 115 | *** Saving and loading snippets has been streamlined. Saving the 116 | snippet to a file will now automatically load it. Additionally, the 117 | buffer will be renamed from "*new snippet*" to whatever the snippet is 118 | named. See also Github #718, #733, and #734. 119 | 120 | *** `yas-escape-text' no longer signals an error when given nil. 121 | 122 | *** `yas-describe-tables' is split into simpler commands. 123 | **** `yas-describe-tables' takes a prefix arg to show non-active tables. 124 | **** New command `yas-describe-tables-by-namehash' shows table by namehash. 125 | 126 | *** Use the region contents as the snippet body of new snippets. 127 | 128 | *** The dependency on `cl' is removed. 129 | Yasnippet now only requires `cl-lib'. 130 | 131 | ** Fixed Bugs 132 | 133 | *** Fix field navigation (tabbing) in the backwards direction. 134 | See Github #722 135 | 136 | *** Add support for deprecated yas/ symbols in `yas-define-menu'. 137 | It was left out by accident. This support is conditional on 138 | `yas-alias-to-yas/prefix-p', just like other obsolete yas/ bindings. 139 | 140 | *** Fix overriding of snippet by a new snippet with same uuid. 141 | See Github #714. 142 | 143 | *** Fix handling of snippets with 2 mirros on the same line. 144 | See Github #712. 145 | 146 | 147 | * 0.10.0 (June 11th, 2016) 148 | 149 | ** Changes and New Features 150 | 151 | *** Yasnippet now prints far fewer message by default. 152 | See Github #682, #683. 153 | 154 | *** `yas-wrap-around-region' can be set to a register. 155 | The register's content will be used. This is like the old `cua' 156 | option, but can be used with any register and doesn't require enabling 157 | cua-mode. 158 | 159 | *** Clearing of snippet fields is now decided by the command's effect. 160 | The `delete-selection' property is no longer consulted. See Github #662. 161 | 162 | *** Empty lines in snippet expansion are no longer indented. 163 | See Github #679. 164 | 165 | *** All lines from mirror output are now indented. 166 | See Github #665. 167 | 168 | *** New variable yas-alias-to-yas/prefix-p 169 | See Github #696, #699. 170 | 171 | *** New function yas-next-field-will-exit-p 172 | See Github #561. 173 | 174 | *** `snippet-mode' is now autoloaded. 175 | 176 | ** Fixed Bugs 177 | 178 | *** Fix incompatibility with Emacs 25 and haskell-mode. 179 | This should also help other modes with a non-nil syntax-propertize 180 | function. See Github #687. 181 | 182 | *** Text property changes no longer disable snippets. 183 | This prevents cc-mode based modes from causing premature exit of 184 | snippets. See Github #677. 185 | 186 | *** Fields are now transformed correctly after `yas-next-field'. 187 | See Github #381. 188 | 189 | *** The $> construct is now escaped correctly, and documented. 190 | See Github #640. 191 | 192 | *** Avoid corruption of snippet content when loading from files. 193 | See Github #707 and Emacs bug #23659. 194 | 195 | *** `yas-wrap-around-region' now works for snippets with fields 196 | farther down the buffer than $0. See Github #636. 197 | 198 | *** The active region is deleted when using `yas-expand'. 199 | This makes it consistent with `yas-insert-snippet'. See Github #523. 200 | 201 | *** Fix mirror+autofill interaction. 202 | See Github #643 and http://emacs.stackexchange.com/q/19206/5296. 203 | 204 | *** Snippet insertion no longer adds irrelevant strings to kill ring. 205 | See Github #675. 206 | 207 | 208 | * 0.9.1 (April 3rd, 2016) 209 | 210 | ** Changes and New Features 211 | 212 | *** Noam Postavsky is now the official yasnippet maintainer. 213 | 214 | *** `yas-visit-snippet-file' now works for compiled snippets (see Github #597). 215 | 216 | *** New function `yas-lookup-snippet' (see Github #595, #596). 217 | 218 | *** .emacs.d/snippets directory is now created automatically. 219 | If that value is present in `yas-snippet-dirs' (see Github #648). 220 | 221 | *** Default value for `yas-snippet-dirs' now uses `user-emacs-directory' 222 | instead of hardcoding "~/emacs.d" (see Github #632). 223 | 224 | *** `yas-visit-snippet-file' no longer overrides `yas-prompt-functions', 225 | see Github #576. 226 | 227 | *** The defaults for prompting have changed. 228 | `yas-x-prompt' is no longer present in the default value of 229 | `yas-prompt-functions'. 230 | 231 | The new function `yas-maybe-ido-prompt' (which performs ido prompting 232 | if `ido-mode' is enabled) replaces `yas-ido-prompt' (which always 233 | performs ido prompting). Previously the behaviour was dependent on 234 | the Emacs version being used. 235 | 236 | *** The default value of `yas-buffer-local-condition' now works for `yas-insert-snippet' too. 237 | See Github #305. 238 | 239 | *** The default value of `yas-new-snippet-default' no longer inserts `require-final-newline: nil'. 240 | It was redundant, since `mode: snippet' already accomplishes the same. 241 | `binding: ${4:direct-keybinding}}' is also removed, as it is hardly 242 | ever wanted. 243 | 244 | *** Snippet fields are only cleared by commands with `delete-selection' property, 245 | See Github #515, #644. 246 | 247 | *** `yas-initialize' (and backward compat alias `yas/initialize') are restored, 248 | but marked obsolete, use (yas-global-mode +1) instead. See Github 249 | #546, #569. 250 | 251 | *** `yas-key-syntaxes' is much more powerful and accepts functions. 252 | Enables use cases when discovering keys based on buffer syntax is not 253 | good enough. See issue #497. 254 | 255 | *** Documentation rewritten in org-mode and updated. 256 | A tremendous effort by Noam Postavsky. Hopefully easier to maintain 257 | and navigate. Available at . 258 | 259 | *** Snippets are now maintained in their own repo. 260 | Snippets live in Andrea Crotti's 261 | . See README.md 262 | for more details. 263 | 264 | *** Textmate snippet importer moved to separate `yasmate' repo. 265 | URL is . See README.md for 266 | more details. 267 | 268 | *** `yas-snippet-dirs' now allows symbols as aliases to directories. 269 | The added level of indirection should allow more esoteric 270 | configurations (see Github #495). 271 | 272 | *** `yas-reload-all' can now jit-load when called interactively. 273 | 274 | *** New `yas-after-reload-hook' run after `yas-reload-all'. 275 | See for the discussion 276 | leading up to this change. 277 | 278 | *** New functions `yas-activate-extra-mode' and `yas-deactivate-extra-mode'. 279 | These are preferable to setting `yas-extra-modes' directly in the mode 280 | hook (see issue #420 for more information). 281 | 282 | *** New variable `yas-new-snippet-default'. 283 | The default snippet suggested on `yas-new-snippet' can now be 284 | customized. 285 | 286 | ** Fixed bugs 287 | 288 | *** `yas-expand' now sets `this-command' when falling back to another command. 289 | Previously it was setting `this-original-command', which does not 290 | match the documented semantics. See Github #587. 291 | 292 | *** Github #537: Be lenient to extensions operating on snippet fields. 293 | 294 | *** Github #619: Parents of extra modes are now activated too. 295 | 296 | *** Github #549: `yas-verbosity' is now applied to `load' calls too. 297 | 298 | *** Github #607; avoid obscure Emacs bug triggered by overlays in *Messages* buffer. 299 | It was triggered by yasnippet+flycheck+highlight-parentheses. See 300 | also 301 | 302 | *** Github #617; fix x prompt when snippet inserts many lines. 303 | 304 | *** Github #618; avoid breakage if `scan-sexp' modifies match data. 305 | Which it does in Emacs 25. 306 | 307 | *** Github #562: Deleting inner numberless snippet caused an error. 308 | 309 | *** Github #418, #536: Fix navigation to zero-length fields at snippet end. 310 | 311 | *** Github #527, #525 and #526: Attempt to prevent "fallback loops" 312 | when interactiing with other extensions that use similar fallback 313 | mechanisms. 314 | 315 | 316 | * 0.8.0 (August 2012) 317 | 318 | ** Changes and New Features 319 | 320 | *** All YASnippet symbols now prefixed with `yas-'. Keep old `yas/' versions as aliases. 321 | 322 | *** Yasnippet is now Free Software Foundation's copyright. 323 | 324 | *** `yas-dont-activate' can be a list of functions. 325 | 326 | *** Snippets are loaded just-in-time . 327 | Thanks to Matthew Fidler for a lot of input with the implementation. 328 | 329 | *** yasnippet-bundle.el is no longer available. 330 | Use `yas-compile-directory' instead if you need the speed advantage. 331 | 332 | *** New functions `yas-compile-directory' and `yas-recompile-all'. 333 | This feature is still undocumented. Generate a 334 | .yas-compiled-snippets.el file in the directory passed where snippets 335 | are compiled into emacs-lisp code. 336 | 337 | *** New `yas-verbosity' variable. 338 | 339 | *** Interactively calling `yas-exit-snippet' exits most recently inserted snippet. 340 | 341 | *** Using filenames as snippet triggers is deprecated. 342 | 343 | *** Default value of `yas-show-menu-p' is `abbreviate'. 344 | 345 | *** `yas-visit-snippet' ignores `yas-prompt-functions'. 346 | 347 | *** `yas-buffer-local-condition' restricted to trigger-key expansions by default. 348 | 349 | *** `yas-load-snippet-buffer' (`C-c C-c') in `snippet-mode' has been much improved. 350 | 351 | *** New variable `yas-expand-only-for-last-commands', thanks Erik Postma. 352 | 353 | *** New variable `yas-extra-modes' aliases old `yas/mode-symbol'. 354 | 355 | *** New `yas-describe-tables' command. 356 | 357 | *** New `yas-define-condition-cache' macro. 358 | This defines an optimised function for placing in a `# condition:' 359 | directive that will run at most once per snippet-expansion attempt. 360 | 361 | *** Mirrors can occur inside fields. 362 | 363 | *** New `# type: command' directive. 364 | This feature is still largely undocumented. 365 | 366 | *** A hidden .yas-setup.el is loaded if found in a snippet directory. 367 | 368 | *** `yas-wrap-around-region' can now also be `cua' (undocumented feature). 369 | 370 | *** Make menu groups automatically using new .yas-make-groups file. 371 | 372 | *** Per-snippet keybindings using `# keybinding:' directive. 373 | 374 | *** More friendly `yas-expand-snippet' calling convention. 375 | This breaks backward compatibility. 376 | 377 | *** The `# env:' directive is now `# expand-env:'. 378 | 379 | *** Setup multiple parent modes using new .yas-parents file. 380 | 381 | ** Fixed bugs 382 | 383 | *** Github #281: jit-load snippets in the correct order. 384 | 385 | *** Github #245: primary field transformations work inside nested fields. 386 | 387 | *** Github #242: stop using the deprecated `assoc' library. 388 | 389 | *** Github #233: show direct snippet keybindings in the menu. 390 | 391 | *** Github #194, Googlecode 192: Compatibility with `fci-mode'. 392 | 393 | *** Github #147, Googlecode 145: Snippets comments were getting inserted. 394 | 395 | *** Github #141, Googlecode 139: searching buffer in embedded elisp works slightly better. 396 | Issue is still open for analysis, though 397 | 398 | *** Github #95, Googlecode 193: no more stack overflow in org-mode. 399 | 400 | 401 | ---------------------------------------------------------------------- 402 | This program is free software; you can redistribute it and/or modify 403 | it under the terms of the GNU General Public License as published by 404 | the Free Software Foundation; either version 3 of the License, or (at 405 | your option) any later version. 406 | 407 | This program is distributed in the hope that it will be useful, but 408 | WITHOUT ANY WARRANTY; without even the implied warranty of 409 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 410 | General Public License for more details. 411 | 412 | 413 | Local variables: 414 | coding: utf-8 415 | mode: outline 416 | paragraph-separate: "[ ]*$" 417 | end: 418 | -------------------------------------------------------------------------------- /src/yasnippet/README.mdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/joaotavora/yasnippet.png)](https://travis-ci.org/joaotavora/yasnippet) 2 | 3 | # Intro 4 | 5 | **YASnippet** is a template system for Emacs. It allows you to 6 | type an abbreviation and automatically expand it into function 7 | templates. Bundled language templates include: C, C++, C#, Perl, 8 | Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax 9 | is inspired from [TextMate's][textmate-snippets] syntax, you can 10 | even [import](#import) most TextMate templates to 11 | YASnippet. Watch [a demo on YouTube][youtube-demo]. 12 | 13 | [textmate-snippets]: http://manual.macromates.com/en/snippets 14 | [youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg 15 | 16 | # Installation 17 | 18 | ## Install the most recent version 19 | 20 | Clone this repository somewhere 21 | 22 | $ cd ~/.emacs.d/plugins 23 | $ git clone --recursive https://github.com/joaotavora/yasnippet 24 | 25 | Add the following in your `.emacs` file: 26 | 27 | (add-to-list 'load-path 28 | "~/.emacs.d/plugins/yasnippet") 29 | (require 'yasnippet) 30 | (yas-global-mode 1) 31 | 32 | Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas-new-snippet`. 33 | 34 | ## Install with `package-install` 35 | 36 | In a recent emacs `M-x list-packages` is the recommended way to list and install packages. 37 | [MELPA][melpa] keeps a very recent snapshot of YASnippet, see http://melpa.org/#installing. 38 | 39 | ## Install with el-get 40 | 41 | El-get is a nice way to get the most recent version, too. See 42 | https://github.com/dimitri/el-get for instructions. 43 | 44 | ## Use `yas-minor-mode` on a per-buffer basis 45 | 46 | To use YASnippet as a non-global minor mode, don't call 47 | `yas-global-mode`; instead call `yas-reload-all` to load the snippet 48 | tables and then call `yas-minor-mode` from the hooks of major-modes 49 | where you want YASnippet enabled. 50 | 51 | (yas-reload-all) 52 | (add-hook 'prog-mode-hook #'yas-minor-mode) 53 | 54 | # Where are the snippets? 55 | 56 | 57 | 58 | Yasnippet no longer bundles snippets directly, but it's very easy to 59 | get some! 60 | 61 | 1. [yasnippet-snippets] - a snippet collection package maintained by 62 | [AndreaCrotti](https://github.com/AndreaCrotti). 63 | 64 | It can be installed with `M-x install-package RET 65 | yasnippet-snippets` if you have added MELPA to your package 66 | sources. 67 | 68 | 2. [yasmate] a tool which is dedicated to converting textmate bundles 69 | into yasnippet snippets. 70 | 71 | To use these snippets you have to run the tool first, so 72 | [see its doc][yasmate]), and then point the `yas-snippet-dirs` 73 | variable to the `.../yasmate/snippets` subdir. 74 | 75 | If you have a working ruby environment, you can probably get lucky 76 | directly with `rake convert-bundles`. 77 | 78 | 3. [textmate-to-yas.el] 79 | 80 | This is another textmate bundle converting tool using Elisp 81 | instead of Ruby. 82 | 83 | Naturally, you can point `yas-snippet-dirs` to good snippet collections out 84 | there. If you have created snippets for a mode, or multiple modes, 85 | consider creating a repository to host them, then tell users that it 86 | should be added like this to `yas-snippet-dirs`: 87 | 88 | (setq yas-snippet-dirs 89 | '("~/.emacs.d/snippets" ;; personal snippets 90 | "/path/to/some/collection/" ;; foo-mode and bar-mode snippet collection 91 | "/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection 92 | )) 93 | 94 | (yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already. 95 | 96 | # Manual, issues etc 97 | 98 | Please refer to the comprehensive [documentation][docs] for full 99 | customisation and support. If you find a bug in the code or in the 100 | documentation, please report it to the main Emacs bug list, 101 | bug-gnu-emacs@gnu.org, and put "yasnippet" somewhere in the subject. 102 | Alternatively, you may use the [Github issue tracker][issues]. 103 | 104 | ## Important note regarding bug reporting 105 | 106 | Your bug reports are very valuable. 107 | 108 | The most important thing when reporting bugs is making sure that we have 109 | a way to reproduce the problem exactly like it happened to you. 110 | 111 | To do this, we need to rule out interference from external factors 112 | like other Emacs extensions or your own customisations. 113 | 114 | Here's an example report that "sandboxes" an Emacs session just for 115 | reproducing a bug. 116 | 117 | ``` 118 | $ emacs --version 119 | Emacs 24.3 120 | $ cd /tmp/ 121 | $ git clone https://github.com/joaotavora/yasnippet.git yasnippet-bug 122 | $ cd yasnippet-bug 123 | $ git log -1 --oneline 124 | 6053db0 Closes #527: Unbreak case where yas-fallback-behaviour is a list 125 | $ HOME=$PWD emacs -L . # This "sandboxes" your emacs, melpa configuration, etc 126 | 127 | (require 'yasnippet) 128 | (yas-global-mode 1) 129 | 130 | When I open a foo-mode file I don't see foo-mode under the "YASnippet" menu! 131 | OR 132 | When loading yasnippet I see "Error: failed to frobnicate"! 133 | ``` 134 | 135 | Using `emacs -Q` or temporarily moving your `.emacs` init file to the side 136 | is another way to achieve good reproducibility. 137 | 138 | Here's a 139 | [another example](https://github.com/joaotavora/yasnippet/issues/318) 140 | of a bug report. It has everything needed for a successful analysis 141 | and speedy resolution. 142 | 143 | Also, don't forget to state the Emacs version (use `M-x emacs-version`) and 144 | the yasnippet version you are using (if using the latest from github, 145 | do `git log -1` in the dir). 146 | 147 | Any more info is welcome, but don't just paste a backtrace or an error 148 | message string you got, unless we ask for it. 149 | 150 | There is also a [YASnippet google group][forum]. I will keep the group 151 | open for reference and for discussion among users. Unfortunately I 152 | can't guarantee a timely response, so maybe it's better to create a 153 | github issue clearly marking your intent (user support/bug/feature 154 | request). 155 | 156 | Finally, thank you very much for using YASnippet! 157 | 158 | [docs]: http://joaotavora.github.io/yasnippet/ 159 | [issues]: https://github.com/joaotavora/yasnippet/issues 160 | [googlecode tracker]: http://code.google.com/p/yasnippet/issues/list 161 | [forum]: http://groups.google.com/group/smart-snippet 162 | [melpa]: http://melpa.milkbox.net/ 163 | [yasmate]: http://github.com/joaotavora/yasmate 164 | [textmate-to-yas.el]: https://github.com/mattfidler/textmate-to-yas.el 165 | [yasnippet-snippets]: http://github.com/AndreaCrotti/yasnippet-snippets 166 | -------------------------------------------------------------------------------- /src/yasnippet/Rakefile: -------------------------------------------------------------------------------- 1 | # -*- Ruby -*- 2 | 3 | require 'fileutils' 4 | 5 | $EMACS = ENV["EMACS"] 6 | if not $EMACS or $EMACS == 't' 7 | $EMACS = "emacs" 8 | end 9 | 10 | def find_version 11 | File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/ 12 | $version = $1 13 | end 14 | find_version 15 | FileUtils.mkdir_p('pkg') 16 | 17 | desc "run tests in batch mode" 18 | task :tests do 19 | sh "#{$EMACS} -Q -L . -l yasnippet-tests.el" + 20 | " --batch -f ert-run-tests-batch-and-exit" 21 | end 22 | 23 | desc "run test in interactive mode" 24 | task :itests do 25 | sh "#{$EMACS} -Q -L . -l yasnippet-tests.el" + 26 | " --eval \"(call-interactively 'ert)\"" 27 | end 28 | 29 | desc "create a release package" 30 | task :package do 31 | release_dir = "pkg/yasnippet-#{$version}" 32 | FileUtils.mkdir_p(release_dir) 33 | files = ['snippets', 'yasnippet.el'] 34 | FileUtils.cp_r files, release_dir 35 | File.open(File.join(release_dir,'yasnippet-pkg.el'), 'w') do |file| 36 | file.puts < [:package, 'doc:archive'] do 50 | raise "Not implemented for github yet!" 51 | end 52 | 53 | desc "Generate document" 54 | task :doc, [:htmlize] do |t, args| 55 | load_path = '-L .' 56 | if args[:htmlize] 57 | load_path += " -L #{args[:htmlize]}" 58 | end 59 | sh "#{$EMACS} -Q #{load_path} --batch -l doc/yas-doc-helper.el" + 60 | " -f yas--generate-html-batch" 61 | end 62 | 63 | namespace :doc do 64 | task :archive do 65 | release_dir = "pkg/yasnippet-#{$version}" 66 | FileUtils.mkdir_p(release_dir) 67 | sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " + 68 | "--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images" 69 | end 70 | 71 | task :upload do 72 | if File.exists? 'doc/gh-pages' 73 | Dir.chdir 'doc/gh-pages' do 74 | sh "git checkout gh-pages" 75 | end 76 | Dir.glob("doc/*.{html,css}").each do |file| 77 | FileUtils.cp file, 'doc/gh-pages' 78 | end 79 | Dir.glob("doc/images/*").each do |file| 80 | FileUtils.cp file, 'doc/gh-pages/images' 81 | end 82 | Dir.glob("doc/stylesheets/*.css").each do |file| 83 | FileUtils.cp file, 'doc/gh-pages/stylesheets' 84 | end 85 | curRev = `git describe`.chomp() 86 | expRev = IO.read('doc/html-revision').chomp() 87 | if curRev != expRev 88 | raise ("The HTML rev: #{expRev},\n" + 89 | "current rev: #{curRev}!\n") 90 | end 91 | Dir.chdir 'doc/gh-pages' do 92 | sh "git commit -a -m 'Automatic documentation update.\n\n" + 93 | "From #{curRev.chomp()}'" 94 | sh "git push" 95 | end 96 | end 97 | end 98 | end 99 | 100 | desc "Compile yasnippet.el into yasnippet.elc" 101 | 102 | rule '.elc' => '.el' do |t| 103 | cmdline = $EMACS + ' --batch -L .' 104 | if ENV['warnings'] 105 | cmdline += " --eval \"(setq byte-compile-warnings #{ENV['warnings']})\"" 106 | end 107 | if ENV['Werror'] 108 | cmdline += " --eval \"(setq byte-compile-error-on-warn #{ENV['Werror']})\"" 109 | end 110 | if ENV['Wlexical'] 111 | cmdline += " --eval \"(setq byte-compile-force-lexical-warnings #{ENV['Wlexical']})\"" 112 | end 113 | cmdline +=" -f batch-byte-compile #{t.source}" 114 | 115 | sh cmdline 116 | end 117 | task :compile => FileList["yasnippet.el"].ext('elc') 118 | task :compile_all => FileList["*.el"].ext('elc') 119 | 120 | task :default => :doc 121 | 122 | desc "use yasmate to convert textmate bundles" 123 | task :convert_bundles do 124 | cd "yasmate" 125 | sh "rake convert_bundles" 126 | end 127 | -------------------------------------------------------------------------------- /src/yasnippet/doc/.nosearch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/.nosearch -------------------------------------------------------------------------------- /src/yasnippet/doc/faq.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: Frequently Asked Questions 4 | 5 | * Why is there an extra newline? 6 | 7 | If there is a newline at the end of a snippet definition file, 8 | YASnippet will add a newline when expanding that snippet. When editing 9 | or saving a snippet file, please be careful not to accidentally add a 10 | terminal newline. 11 | 12 | Note that some editors will automatically add a newline for you. In 13 | Emacs, if you set =require-final-newline= to =t=, it will add the 14 | final newline automatically. 15 | 16 | * Why doesn't TAB navigation work with flyspell 17 | 18 | A workaround is to inhibit flyspell overlays while the snippet is 19 | active: 20 | 21 | #+BEGIN_SRC emacs-lisp 22 | (add-hook 'flyspell-incorrect-hook 23 | #'(lambda (dummy1 dummy2 dymmy3) 24 | (and yas-active-field-overlay 25 | (overlay-buffer yas-active-field-overlay)))) 26 | #+END_SRC 27 | 28 | This is apparently related to overlay priorities. For some reason, the 29 | =keymap= property of flyspell's overlays always takes priority over the 30 | same property in YASnippet's overlays, even if one sets the latter's 31 | =priority= property to something big. If you know emacs-lisp and can 32 | solve this problem, drop a line in the 33 | [[http://groups.google.com/group/smart-snippet][discussion group]]. 34 | 35 | * How do I use alternative keys, i.e. not TAB? 36 | 37 | Edit the keymaps [[sym:yas-minor-mode-map][=yas-minor-mode-map=]] and 38 | [[sym:yas-keymap][=yas-keymap=]] as you would any other keymap: 39 | 40 | #+begin_src emacs-lisp :exports code 41 | (define-key yas-minor-mode-map (kbd "") nil) 42 | (define-key yas-minor-mode-map (kbd "TAB") nil) 43 | (define-key yas-minor-mode-map (kbd "") yas-maybe-expand) 44 | 45 | ;;keys for navigation 46 | (define-key yas-keymap [(tab)] nil) 47 | (define-key yas-keymap (kbd "TAB") nil) 48 | (define-key yas-keymap [(shift tab)] nil) 49 | (define-key yas-keymap [backtab] nil) 50 | (define-key yas-keymap (kbd "") 'yas-next-field-or-maybe-expand) 51 | (define-key yas-keymap (kbd "") 'yas-prev) 52 | #+end_src 53 | 54 | * How do I turn off the minor mode where in some buffers? 55 | 56 | The best way, since version 0.6.1c, is to set the default value of the 57 | variable [[sym:yas-dont-activate][=yas-dont-activate=]] to a lambda function like so: 58 | 59 | #+BEGIN_SRC emacs-lisp 60 | (set-default 'yas-dont-activate 61 | #'(lambda () 62 | (and yas-root-directory 63 | (null (yas-get-snippet-tables))))) 64 | #+END_SRC 65 | 66 | This is also the default value starting for that version. It skips the 67 | minor mode in buffers where it is not applicable (no snippet tables), 68 | but only once you have setup your yas-root-directory. 69 | 70 | * How do I define an abbrev key containing characters not supported by the filesystem? 71 | 72 | - *Note*: This question applies if you're still defining snippets 73 | whose key /is/ the filename. This is behavior still provided by 74 | version 0.6 for backward compatibilty, but is somewhat 75 | deprecated... 76 | 77 | For example, you want to define a snippet by the key =<= which is not a 78 | valid character for filename on Windows. This means you can't use the 79 | filename as a trigger key in this case. 80 | 81 | You should rather use the =# key:= directive to specify the key of the 82 | defined snippet explicitly and name your snippet with an arbitrary valid 83 | filename, =lt.YASnippet= for example, using =<= for the =# key:= 84 | directive: 85 | 86 | #+BEGIN_SRC snippet 87 | # key: < 88 | # name: <...> 89 | # -- 90 | <${1:div}>$0 91 | #+END_SRC 92 | -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-content-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-content-left.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-content-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-content-right.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-content.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-navigation-item-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-navigation-item-hover.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-navigation-item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-navigation-item.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/bg-navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/bg-navigation.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/body.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/body.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/customization-group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/customization-group.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/dropdown-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/dropdown-menu.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/external.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/ido-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/ido-menu.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/menu-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/menu-1.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/menu-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/menu-2.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/menu-groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/menu-groups.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/menu-parent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/menu-parent.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/minor-mode-indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/minor-mode-indicator.png -------------------------------------------------------------------------------- /src/yasnippet/doc/images/x-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/doc/images/x-menu.png -------------------------------------------------------------------------------- /src/yasnippet/doc/index.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | #+TITLE: Yet another snippet extension 3 | 4 | The YASnippet documentation has been split into separate parts: 5 | 6 | 0. [[https://github.com/joaotavora/yasnippet/blob/master/README.mdown][README]] 7 | 8 | Contains an introduction, installation instructions and other important 9 | notes. 10 | 11 | 1. [[file:snippet-organization.org][Organizing Snippets]] 12 | 13 | Describes ways to organize your snippets in the hard disk. 14 | 15 | 2. [[file:snippet-expansion.org][Expanding Snippets]] 16 | 17 | Describes how YASnippet chooses snippets for expansion at point. 18 | 19 | Maybe, you'll want some snippets to be expanded in a particular mode, 20 | or only under certain conditions, or be prompted using =ido=, etc... 21 | 22 | 3. [[file:snippet-development.org][Writing Snippets]] 23 | 24 | Describes the YASnippet definition syntax, which is very close (but 25 | not equivalent) to Textmate's. Includes a section about converting 26 | TextMate snippets. 27 | 28 | 4. [[file:snippet-menu.org][The YASnippet menu]] 29 | 30 | Explains how to use the YASnippet menu to explore, learn and modify 31 | snippets. 32 | 33 | 5. [[file:faq.org][Frequently asked questions]] 34 | 35 | Answers to frequently asked questions. 36 | 37 | 6. [[file:snippet-reference.org][YASnippet Symbol Reference]] 38 | 39 | An automatically generated listing of all YASnippet commands, 40 | (customization) variables, and functions. 41 | 42 | 43 | # Local Variables: 44 | # mode: org 45 | # fill-column: 80 46 | # coding: utf-8 47 | # End: 48 | -------------------------------------------------------------------------------- /src/yasnippet/doc/nav-menu.html.inc: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /src/yasnippet/doc/org-setup.inc: -------------------------------------------------------------------------------- 1 | # -*- mode: org -*- 2 | 3 | #+STARTUP: showall 4 | 5 | #+LINK: sym file:snippet-reference.org::#%s 6 | 7 | #+OPTIONS: author:nil num:nil timestamp:nil 8 | #+AUTHOR: 9 | # org < 8.0 use +STYLE, after use +HTML_HEAD 10 | #+STYLE: 11 | #+HTML_HEAD: 12 | -------------------------------------------------------------------------------- /src/yasnippet/doc/snippet-development.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: Writing snippets 4 | 5 | * Snippet development 6 | 7 | ** Quickly finding snippets 8 | 9 | There are some ways you can quickly find a snippet file or create a new one: 10 | 11 | - =M-x yas-new-snippet=, key bindind: =C-c & C-n= 12 | 13 | Creates a new buffer with a template for making a new snippet. The 14 | buffer is in =snippet-mode= (see [[snippet-mode][below]]). When you are done editing 15 | the new snippet, use [[yas-load-snippet-buffer-and-close][=C-c C-c=]] to save it. 16 | 17 | - =M-x yas-visit-snippet-file=, key binding: =C-c & C-v= 18 | 19 | Prompts you for possible snippet expansions like 20 | [[sym:yas-insert-snippet][=yas-insert-snippet=]], but instead of expanding it, takes you directly 21 | to the snippet definition's file, if it exists. 22 | 23 | Once you find this file it will be set to =snippet-mode= (see [[snippet-mode][ahead]]) 24 | and you can start editing your snippet. 25 | 26 | ** Using the =snippet-mode= major mode <> 27 | 28 | There is a major mode =snippet-mode= to edit snippets. You can set the 29 | buffer to this mode with =M-x snippet-mode=. It provides reasonably 30 | useful syntax highlighting. 31 | 32 | Three commands are defined in this mode: 33 | 34 | - =M-x yas-load-snippet-buffer=, key binding: =C-c C-l= 35 | 36 | Prompts for a snippet table (with a default based on snippet's 37 | major mode) and loads the snippet currently being edited. 38 | 39 | - =M-x yas-load-snippet-buffer-and-close=, key binding: =C-c C-c= 40 | <> 41 | 42 | Like =yas-load-snippet-buffer=, but also saves the snippet and 43 | calls =quit-window=. The destination is decided based on the 44 | chosen snippet table and snippet collection directly (defaulting to 45 | the first directory in =yas-snippet-dirs= (see [[file:snippet-organization.org][Organizing Snippets]] 46 | for more detail on how snippets are organized). 47 | 48 | - =M-x yas-tryout-snippet=, key binding: =C-c C-t= 49 | 50 | When editing a snippet, this opens a new empty buffer, sets it to 51 | the appropriate major mode and inserts the snippet there, so you 52 | can see what it looks like. 53 | 54 | There are also /snippets for writing snippets/: =vars=, =$f= and =$m= 55 | :-). 56 | 57 | * File content 58 | 59 | A file defining a snippet generally contains the template to be 60 | expanded. 61 | 62 | Optionally, if the file contains a line of =# --=, the lines above it 63 | count as comments, some of which can be /directives/ (or meta data). 64 | Snippet directives look like =# property: value= and tweak certain 65 | snippets properties described below. If no =# --= is found, the whole 66 | file is considered the snippet template. 67 | 68 | Here's a typical example: 69 | 70 | #+BEGIN_SRC snippet 71 | # contributor: pluskid 72 | # name: __...__ 73 | # -- 74 | __${init}__ 75 | #+END_SRC 76 | 77 | Here's a list of currently supported directives: 78 | 79 | ** =# key:= snippet abbrev 80 | 81 | This is the probably the most important directive, it's the 82 | abbreviation you type to expand a snippet just before hitting the key 83 | that runs [[sym:yas-expand][=yas-expand=]]. If you don't specify this, 84 | the snippet will not be expandable through the trigger mechanism. 85 | 86 | ** =# name:= snippet name 87 | 88 | This is a one-line description of the snippet. It will be displayed in 89 | the menu. It's a good idea to select a descriptive name for a snippet -- 90 | especially distinguishable among similar snippets. 91 | 92 | If you omit this name, it will default to the file name the snippet 93 | was loaded from. 94 | 95 | ** =# condition:= snippet condition 96 | 97 | This is a piece of Emacs-lisp code. If a snippet has a condition, then 98 | it will only be expanded when the condition code evaluate to some 99 | non-nil value. 100 | 101 | See also [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] in 102 | [[./snippet-expansion.org][Expanding snippets]] 103 | 104 | ** =# group:= snippet menu grouping 105 | 106 | When expanding/visiting snippets from the menu-bar menu, snippets for a 107 | given mode can be grouped into sub-menus . This is useful if one has too 108 | many snippets for a mode which will make the menu too long. 109 | 110 | The =# group:= property only affect menu construction (See 111 | [[./snippet-menu.org][the YASnippet menu]]) and the same effect can be 112 | achieved by grouping snippets into sub-directories and using the 113 | =.yas-make-groups= special file (for this see 114 | [[./snippet-organization.org][Organizing Snippets]] 115 | 116 | Refer to the bundled snippets for =ruby-mode= for examples on the 117 | =# group:= directive. Group can also be nested, e.g. 118 | =control structure.loops= tells that the snippet is under the =loops= 119 | group which is under the =control structure= group. 120 | 121 | ** =# expand-env:= expand environment 122 | 123 | This is another piece of Emacs-lisp code in the form of a =let= /varlist 124 | form/, i.e. a list of lists assigning values to variables. It can be 125 | used to override variable values while the snippet is being expanded. 126 | 127 | Interesting variables to override are [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] and 128 | [[sym:yas-indent-line][=yas-indent-line=]] (see [[./snippet-expansion.org][Expanding Snippets]]). 129 | 130 | As an example, you might normally have [[sym:yas-indent-line][=yas-indent-line=]] set to '=auto= 131 | and [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] set to =t=, but for this particularly 132 | brilliant piece of ASCII art these values would mess up your hard work. 133 | You can then use: 134 | 135 | #+BEGIN_SRC snippet 136 | # name: ASCII home 137 | # expand-env: ((yas-indent-line 'fixed) (yas-wrap-around-region 'nil)) 138 | # -- 139 | welcome to my 140 | X humble 141 | / \ home, 142 | / \ $0 143 | / \ 144 | /-------\ 145 | | | 146 | | +-+ | 147 | | | | | 148 | +--+-+--+ 149 | #+END_SRC 150 | 151 | ** =# binding:= direct keybinding 152 | 153 | You can use this directive to expand a snippet directly from a normal 154 | Emacs keybinding. The keybinding will be registered in the Emacs keymap 155 | named after the major mode the snippet is active for. 156 | 157 | Additionally a variable [[sym:yas-prefix][=yas-prefix=]] is set to to the prefix argument 158 | you normally use for a command. This allows for small variations on the 159 | same snippet, for example in this "html-mode" snippet. 160 | 161 | #+BEGIN_SRC snippet 162 | # name:

...

163 | # binding: C-c C-c C-m 164 | # -- 165 |

`(when yas-prefix "\n")`$0`(when yas-prefix "\n")`

166 | #+END_SRC 167 | 168 | This binding will be recorded in the keymap =html-mode-map=. To expand a 169 | paragraph tag newlines, just press =C-u C-c C-c C-m=. Omitting the =C-u= 170 | will expand the paragraph tag without newlines. 171 | 172 | ** =# type:= =snippet= or =command= 173 | 174 | If the =type= directive is set to =command=, the body of the snippet 175 | is interpreted as lisp code to be evaluated when the snippet is 176 | triggered. 177 | 178 | If it's =snippet= (the default when there is no =type= directive), the 179 | snippet body will be parsed according to the [[Template Syntax]], 180 | described below. 181 | 182 | ** =# uuid:= unique identifier 183 | 184 | This provides to a way to identify a snippet, independent of its name. 185 | Loading a second snippet file with the same uuid would replace the 186 | previous snippet. 187 | 188 | ** =# contributor:= snippet author 189 | 190 | This is optional and has no effect whatsoever on snippet functionality, 191 | but it looks nice. 192 | 193 | * Template Syntax 194 | 195 | The syntax of the snippet template is simple but powerful, very similar 196 | to TextMate's. 197 | 198 | ** Plain Text 199 | 200 | Arbitrary text can be included as the content of a template. They are 201 | usually interpreted as plain text, except =$= and =`=. You need to 202 | use =\= to escape them: =\$= and =\`=. The =\= itself may also needed to be 203 | escaped as =\\= sometimes. 204 | 205 | ** Embedded Emacs-lisp code 206 | 207 | Emacs-Lisp code can be embedded inside the template, written inside 208 | back-quotes (=`=). The lisp forms are evaluated when the snippet is 209 | being expanded. The evaluation is done in the same buffer as the 210 | snippet being expanded. 211 | 212 | Here's an example for c-mode to calculate the header file guard 213 | dynamically: 214 | 215 | #+BEGIN_SRC snippet 216 | #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_} 217 | #define $1 218 | 219 | $0 220 | 221 | #endif /* $1 */ 222 | #+END_SRC 223 | 224 | From version 0.6, snippets expansions are run with some special 225 | Emacs-lisp variables bound. One of this is [[sym:yas-selected-text][=yas-selected-text=]]. You can 226 | therefore define a snippet like: 227 | 228 | #+BEGIN_SRC snippet 229 | for ($1;$2;$3) { 230 | `yas-selected-text`$0 231 | } 232 | #+END_SRC 233 | 234 | to "wrap" the selected region inside your recently inserted snippet. 235 | Alternatively, you can also customize the variable 236 | [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] to =t= which will do this automatically. 237 | 238 | *** Note: backquote expressions should not modify the buffer 239 | 240 | Please note that the lisp forms in backquotes should *not* modify the 241 | buffer, doing so will trigger a warning. For example, instead of 242 | doing 243 | 244 | #+BEGIN_SRC snippet 245 | Timestamp: `(insert (current-time-string))` 246 | #+END_SRC 247 | 248 | do this: 249 | #+BEGIN_SRC snippet 250 | Timestamp: `(current-time-string)` 251 | #+END_SRC 252 | 253 | The warning may be suppressed with the following code in your init file: 254 | #+BEGIN_SRC emacs-lisp 255 | (add-to-list 'warning-suppress-types '(yasnippet backquote-change)) 256 | #+END_SRC 257 | 258 | 259 | ** Tab stop fields 260 | 261 | Tab stops are fields that you can navigate back and forth by =TAB= and 262 | =S-TAB=. They are written by =$= followed with a number. =$0= has the 263 | special meaning of the /exit point/ of a snippet. That is the last place 264 | to go when you've traveled all the fields. Here's a typical example: 265 | 266 | #+BEGIN_SRC snippet 267 | 268 | $0 269 | 270 | #+END_SRC 271 | ** Placeholder fields 272 | 273 | Tab stops can have default values -- a.k.a placeholders. The syntax is 274 | like this: 275 | 276 | #+BEGIN_SRC snippet 277 | ${N:default value} 278 | #+END_SRC 279 | 280 | They act as the default value for a tab stop. But when you first 281 | type at a tab stop, the default value will be replaced by your typing. 282 | The number can be omitted if you don't want to create [[mirrors-fields][mirrors]] or 283 | [[mirror-transformations][transformations]] for this field. 284 | 285 | ** Mirrors <> 286 | 287 | We refer the tab stops with placeholders as a /field/. A field can have 288 | mirrors. Its mirrors will get updated when you change the text of a 289 | field. Here's an example: 290 | 291 | #+BEGIN_SRC snippet 292 | \begin{${1:enumerate}} 293 | $0 294 | \end{$1} 295 | #+END_SRC 296 | 297 | When you type "document" at =${1:enumerate}=, the word "document" will 298 | also be inserted at =\end{$1}=. The best explanation is to see the 299 | screencast([[http://www.youtube.com/watch?v=vOj7btx3ATg][YouTube]] or [[http://yasnippet.googlecode.com/files/yasnippet.avi][avi video]]). 300 | 301 | The tab stops with the same number to the field act as its mirrors. If 302 | none of the tab stops has an initial value, the first one is selected as 303 | the field and others mirrors. 304 | 305 | ** Mirrors with transformations <> 306 | 307 | If the value of an =${n:=-construct starts with and contains =$(=, 308 | then it is interpreted as a mirror for field =n= with a 309 | transformation. The mirror's text content is calculated according to 310 | this transformation, which is Emacs-lisp code that gets evaluated in 311 | an environment where the variable [[sym:yas-text][=yas-text=]] is bound to the text 312 | content (string) contained in the field =n=. Here's an example for 313 | Objective-C: 314 | 315 | #+BEGIN_SRC snippet 316 | - (${1:id})${2:foo} 317 | { 318 | return $2; 319 | } 320 | 321 | - (void)set${2:$(capitalize yas-text)}:($1)aValue 322 | { 323 | [$2 autorelease]; 324 | $2 = [aValue retain]; 325 | } 326 | $0 327 | #+END_SRC 328 | 329 | Look at =${2:$(capitalize yas-text)}=, it is a mirror with 330 | transformation instead of a field. The actual field is at the first 331 | line: =${2:foo}=. When you type text in =${2:foo}=, the transformation 332 | will be evaluated and the result will be placed there as the 333 | transformed text. So in this example, if you type "baz" in the field, 334 | the transformed text will be "Baz". This example is also available in 335 | the screencast. 336 | 337 | Another example is for =rst-mode=. In reStructuredText, the document 338 | title can be some text surrounded by "===" below and above. The "===" 339 | should be at least as long as the text. So 340 | 341 | #+BEGIN_SRC rst 342 | ===== 343 | Title 344 | ===== 345 | #+END_SRC 346 | 347 | is a valid title but 348 | 349 | #+BEGIN_SRC rst 350 | === 351 | Title 352 | === 353 | #+END_SRC 354 | 355 | is not. Here's an snippet for rst title: 356 | 357 | #+BEGIN_SRC snippet 358 | ${1:$(make-string (string-width yas-text) ?\=)} 359 | ${1:Title} 360 | ${1:$(make-string (string-width yas-text) ?\=)} 361 | 362 | $0 363 | #+END_SRC 364 | 365 | ** Fields with transformations 366 | 367 | From version 0.6 on, you can also have lisp transformation inside 368 | fields. These work mostly like mirror transformations. However, they 369 | are evaluated when you first enter the field, after each change you 370 | make to the field and also just before you exit the field. 371 | 372 | The syntax is also a tiny bit different, so that the parser can 373 | distinguish between fields and mirrors. In the following example 374 | 375 | : #define "${1:mydefine$(upcase yas-text)}" 376 | 377 | =mydefine= gets automatically upcased to =MYDEFINE= once you enter the 378 | field. As you type text, it gets filtered through the transformation 379 | every time. 380 | 381 | Note that to tell this kind of expression from a mirror with a 382 | transformation, YASnippet needs extra text between the =:= and the 383 | transformation's =$=. If you don't want this extra-text, you can use two 384 | =$='s instead. 385 | 386 | : #define "${1:$$(upcase yas-text)}" 387 | 388 | Please note that as soon as a transformation takes place, it changes the 389 | value of the field and sets it its internal modification state to 390 | =true=. As a consequence, the auto-deletion behaviour of normal fields 391 | does not take place. This is by design. 392 | 393 | ** Choosing fields value from a list and other tricks 394 | 395 | As mentioned, the field transformation is invoked just after you enter 396 | the field, and with some useful variables bound, notably 397 | [[sym:yas-modified-p][=yas-modified-p=]] and [[sym:yas-moving-away-p][=yas-moving-away-p=]]. Because of this feature you 398 | can place a transformation in the primary field that lets you select 399 | default values for it. 400 | 401 | The [[sym:yas-choose-value][=yas-choose-value=]] does this work for you. For example: 402 | 403 | #+BEGIN_SRC snippet 404 |
405 | $0 406 |
407 | #+END_SRC 408 | 409 | See the definition of [[sym:yas-choose-value][=yas-choose-value=]] to see how it was written using 410 | the two variables. 411 | 412 | Here's another use, for LaTeX-mode, which calls reftex-label just as you 413 | enter snippet field 2. This one makes use of [[sym:yas-modified-p][=yas-modified-p=]] directly. 414 | 415 | #+BEGIN_SRC snippet 416 | \section{${1:"Titel der Tour"}}% 417 | \index{$1}% 418 | \label{{2:"waiting for reftex-label call..."$(unless yas-modified-p (reftex-label nil 'dont- 419 | insert))}}% 420 | #+END_SRC 421 | 422 | The function [[sym:yas-verify-value][=yas-verify-value=]] has another neat trick, and makes use 423 | of [[sym:yas-moving-away-p][=yas-moving-away-p=]]. Try it and see! Also, check out this [[http://groups.google.com/group/smart-snippet/browse_thread/thread/282a90a118e1b662][thread]] 424 | 425 | ** Nested placeholder fields 426 | 427 | From version 0.6 on, you can also have nested placeholders of the type: 428 | 429 | #+BEGIN_SRC snippet 430 | $0 431 | #+END_SRC 432 | 433 | This allows you to choose if you want to give this =div= an =id= 434 | attribute. If you tab forward after expanding, it will let you change 435 | "some\_id" to whatever you like. Alternatively, you can just press =C-d= 436 | (which executes [[sym:yas-skip-and-clear-or-delete-char][=yas-skip-and-clear-or-delete-char=]]) and go straight to 437 | the exit marker. 438 | 439 | By the way, =C-d= will only clear the field if you cursor is at the 440 | beginning of the field /and/ it hasn't been changed yet. Otherwise, it 441 | performs the normal Emacs =delete-char= command. 442 | 443 | ** Indentation markers 444 | 445 | If [[sym:yas-indent-line][=yas-indent-line=]] is *not* set to '=auto=, it's still possible to 446 | indent specific lines by adding an indentation marker, =$>=, somewhere 447 | on the line. 448 | -------------------------------------------------------------------------------- /src/yasnippet/doc/snippet-expansion.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: Expanding snippets 4 | 5 | This section describes how YASnippet chooses snippets for expansion at point. 6 | 7 | Maybe, you'll want some snippets to be expanded in a particular 8 | mode, or only under certain conditions, or be prompted using 9 | 10 | * Triggering expansion 11 | 12 | You can use YASnippet to expand snippets in different ways: 13 | 14 | - When [[sym:yas-minor-mode][=yas-minor-mode=]] is active: 15 | - Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]] 16 | (bound to =TAB= by default). 17 | 18 | - Use the snippet's *keybinding*. 19 | 20 | - By expanding directly from the "YASnippet" menu in the menu-bar 21 | 22 | - Using hippie-expand 23 | 24 | - Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x yas-insert-snippet== or its 25 | keybinding =C-c & C-s=). 26 | 27 | - Use m2m's excellent auto-complete 28 | TODO: example for this 29 | 30 | - Expanding from emacs-lisp code 31 | 32 | ** Trigger key 33 | 34 | [[sym:yas-expand][=yas-expand=]] tries to expand a /snippet abbrev/ (also known as 35 | /snippet key/) before point. YASnippet also provides a /conditional 36 | binding/ for this command: the variable [[sym:yas-expand][=yas-maybe-expand=]] contains a 37 | special value which, when bound in a keymap, tells Emacs to call 38 | [[sym:yas-expand][=yas-expand=]] if and only if there is a snippet abbrev before point. 39 | If there is no snippet to expand, Emacs will behave as if [[sym:yas-expand][=yas-expand=]] 40 | is unbound and so will run whatever command is bound to that key 41 | normally. 42 | 43 | When [[sym:yas-minor-mode][=yas-minor-mode=]] is enabled, it binds [[sym:yas-maybe-expand][=yas-maybe-expand=]] to =TAB= 44 | and == by default, however, you can freely remove those bindings: 45 | 46 | #+begin_src emacs-lisp :exports code 47 | (define-key yas-minor-mode-map (kbd "") nil) 48 | (define-key yas-minor-mode-map (kbd "TAB") nil) 49 | #+end_src 50 | 51 | And set your own: 52 | 53 | #+begin_src emacs-lisp :exports code 54 | ;; Bind `SPC' to `yas-expand' when snippet expansion available (it 55 | ;; will still call `self-insert-command' otherwise). 56 | (define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand) 57 | ;; Bind `C-c y' to `yas-expand' ONLY. 58 | (define-key yas-minor-mode-map (kbd "C-c y") #'yas-expand) 59 | #+end_src 60 | 61 | 62 | To enable the YASnippet minor mode in all buffers globally use the 63 | command [[sym:yas-global-mode][=yas-global-mode=]]. This will enable a modeline indicator, 64 | =yas=: 65 | 66 | [[./images/minor-mode-indicator.png]] 67 | 68 | When you use [[sym:yas-global-mode][=yas-global-mode=]] you can also selectively disable 69 | YASnippet in some buffers by calling [[sym:yas-minor-mode][=yas-minor-mode=]] with a negative 70 | argument in the buffer's mode hook. 71 | 72 | *** Fallback behaviour 73 | 74 | YASnippet used to support a more complicated way of sharing 75 | keybindings before [[sym:yas-expand][=yas-maybe-expand=]] was added. This is now 76 | obsolete. 77 | 78 | ** Insert at point 79 | 80 | The command [[#yas-insert-snippet][=yas-insert-snippet=]] lets you insert snippets at point 81 | /for your current major mode/. It prompts you for the snippet key 82 | first, and then for a snippet template if more than one template 83 | exists for the same key. 84 | 85 | The list presented contains the snippets that can be inserted at point, 86 | according to the condition system. If you want to see all applicable 87 | snippets for the major mode, prefix this command with =C-u=. 88 | 89 | The prompting methods used are again controlled by 90 | [[sym:yas-prompt-functions][=yas-prompt-functions=]]. 91 | 92 | *** Inserting region or register contents into snippet 93 | 94 | It's often useful to inject already written text in the middle of a 95 | snippet. The variable [[sym:yas-wrap-around-region][=yas-wrap-around-region=]] when to t substitute 96 | the region contents into the =$0= placeholder of a snippet expanded by 97 | [[#yas-insert-snippet][=yas-insert-snippet=]]. Setting it to a character value (e.g. =?0=) 98 | will insert the contents of corresponding register. 99 | 100 | Older (versions 0.9.1 and below) of Yasnippet, supported a setting of 101 | =cua= that is equivalent to =?0= but only worked with =cua-mode= 102 | turned on. This setting is still supported for backwards 103 | compatibility, but is now entirely equivalent to =?0=. 104 | 105 | ** Snippet keybinding 106 | 107 | See the section of the =# binding:= directive in 108 | [[./snippet-development.org][Writing Snippets]]. 109 | 110 | ** Expanding from the menu 111 | 112 | See [[./snippet-menu.org][the YASnippet Menu]]. 113 | 114 | ** Expanding with =hippie-expand= 115 | 116 | To integrate with =hippie-expand=, just put 117 | [[sym:yas-hippie-try-expand][=yas-hippie-try-expand=]] in 118 | =hippie-expand-try-functions-list=. This probably makes more sense 119 | when placed at the top of the list, but it can be put anywhere you 120 | prefer. 121 | 122 | ** Expanding from emacs-lisp code 123 | 124 | Sometimes you might want to expand a snippet directly from your own 125 | elisp code. You should call [[sym:yas-expand-snippet][=yas-expand-snippet=]] instead of 126 | [[sym:yas-expand][=yas-expand=]] in this case. [[sym:yas-expand-snippet][=yas-expand-snippet=]] takes a string in 127 | snippet template syntax, if you want to expand an existing snippet you 128 | can use [[sym:yas-lookup-snippet][=yas-lookup-snippet=]] to find its contents by name. 129 | 130 | As with expanding from the menubar, the condition system and multiple 131 | candidates doesn't affect expansion (the condition system does affect 132 | [[sym:yas-lookup-snippet][=yas-lookup-snippet=]] though). In fact, expanding from the YASnippet 133 | menu has the same effect of evaluating the follow code: 134 | 135 | #+BEGIN_SRC emacs-lisp 136 | (yas-expand-snippet template) 137 | #+END_SRC 138 | 139 | See the internal documentation on [[sym:yas-expand-snippet][=yas-expand-snippet=]] and 140 | [[sym:yas-lookup-snippet][=yas-lookup-snippet=]] for more information. 141 | 142 | * Controlling expansion 143 | 144 | ** Eligible snippets 145 | 146 | YASnippet does quite a bit of filtering to find out which snippets are 147 | eligible for expanding at the current cursor position. 148 | 149 | In particular, the following things matter: 150 | 151 | - Currently loaded snippets tables 152 | 153 | These are loaded from a directory hierarchy in your file system. See 154 | [[./snippet-organization.org][Organizing Snippets]]. They are named 155 | after major modes like =html-mode=, =ruby-mode=, etc... 156 | 157 | - Major mode of the current buffer 158 | 159 | If the currrent major mode matches one of the loaded snippet tables, 160 | then all that table's snippets are considered for expansion. Use 161 | =M-x describe-variable RET major-mode RET= to find out which major 162 | mode you are in currently. 163 | 164 | - Parent tables 165 | 166 | Snippet tables defined as the parent of some other eligible table are 167 | also considered. This works recursively, i.e. parents of parents of 168 | eligible tables are also considered. 169 | 170 | - Buffer-local list of extra modes 171 | 172 | Use [[#yas-activate-extra-mode][=yas-activate-extra-mode=]] to 173 | consider snippet tables whose name does not correspond to a major 174 | mode. Typically, you call this from a minor mode hook, for example: 175 | 176 | #+BEGIN_SRC emacs-lisp 177 | ;; When entering rinari-minor-mode, consider also the snippets in the 178 | ;; snippet table "rails-mode" 179 | (add-hook 'rinari-minor-mode-hook 180 | #'(lambda () 181 | (yas-activate-extra-mode 'rails-mode))) 182 | #+END_SRC 183 | 184 | - Buffer-local [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] variable 185 | 186 | This variable provides finer grained control over what snippets can 187 | be expanded in the current buffer. For example, the constant 188 | [[sym:yas-not-string-or-comment-condition][=yas-not-string-or-comment-condition=]] has a value that disables 189 | snippet expansion inside comments or string literals. See [[condition-system][the 190 | condition system]] for more info. 191 | 192 | ** The condition system <> 193 | 194 | Consider this scenario: you are an old Emacs hacker. You like the 195 | abbrev-way and bind [[sym:yas-expand][=yas-expand=]] to =SPC=. However, you don't want 196 | =if= to be expanded as a snippet when you are typing in a comment 197 | block or a string (e.g. in =python-mode=). 198 | 199 | If you use the =# condition := directive (see [[./snippet-development.org][Writing Snippets]]) you 200 | could just specify the condition for =if= to be =(not 201 | (python-syntax-comment-or-string-p))=. But how about =while=, =for=, 202 | etc? Writing the same condition for all the snippets is just boring. 203 | So you can instead set [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] to =(not 204 | (python-syntax-comment-or-string-p))= in =python-mode-hook=. 205 | 206 | Then, what if you really want some particular snippet to expand even 207 | inside a comment? Set [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]] like this 208 | 209 | #+BEGIN_SRC emacs-lisp 210 | (add-hook 'python-mode-hook 211 | (lambda () 212 | (setq yas-buffer-local-condition 213 | '(if (python-syntax-comment-or-string-p) 214 | '(require-snippet-condition . force-in-comment) 215 | t)))) 216 | #+END_SRC 217 | 218 | ... and for a snippet that you want to expand in comments, specify a 219 | condition which evaluates to the symbol =force-in-comment=. Then it 220 | can be expanded as you expected, while other snippets like =if= still 221 | can't expanded in comments. 222 | 223 | For the full set of possible conditions, see the documentation for 224 | [[sym:yas-buffer-local-condition][=yas-buffer-local-condition=]]. 225 | 226 | ** Multiples snippet with the same key 227 | 228 | The rules outlined [[Eligible%20snippets][above]] can return more than 229 | one snippet to be expanded at point. 230 | 231 | When there are multiple candidates, YASnippet will let you select one. 232 | The UI for selecting multiple candidate can be customized through 233 | [[sym:yas-prompt-functions][=yas-prompt-functions=]] , which defines your preferred methods of being 234 | prompted for snippets. 235 | 236 | You can customize it with 237 | =M-x customize-variable RET yas-prompt-functions RET=. Alternatively you 238 | can put in your emacs-file: 239 | 240 | #+BEGIN_SRC emacs-lisp 241 | (setq yas-prompt-functions '(yas-x-prompt yas-dropdown-prompt)) 242 | #+END_SRC 243 | 244 | Currently there are some alternatives solution with YASnippet. 245 | 246 | *** Use the X window system 247 | 248 | [[./images/x-menu.png]] 249 | 250 | The function [[sym:yas-x-prompt][=yas-x-prompt=]] can be used to show a popup menu for you to 251 | select. This menu will be part of you native window system widget, which 252 | means: 253 | 254 | - It usually looks beautiful. E.g. when you compile Emacs with gtk 255 | support, this menu will be rendered with your gtk theme. 256 | - Your window system may or may not allow to you use =C-n=, =C-p= to 257 | navigate this menu. 258 | - This function can't be used when in a terminal. 259 | 260 | *** Minibuffer prompting 261 | 262 | [[./images/ido-menu.png]] 263 | 264 | You can use functions [[sym:yas-completing-prompt][=yas-completing-prompt=]] for the classic emacs 265 | completion method or [[sym:yas-ido-prompt][=yas-ido-prompt=]] for a much nicer looking method. 266 | The best way is to try it. This works in a terminal. 267 | 268 | *** Use =dropdown-menu.el= 269 | 270 | [[./images/dropdown-menu.png]] 271 | 272 | The function [[sym:yas-dropdown-prompt][=yas-dropdown-prompt=]] can also be placed in the 273 | [[sym:yas-prompt-functions][=yas-prompt-functions=]] list. 274 | 275 | This works in both window system and terminal and is customizable, you 276 | can use =C-n=, =C-p= to navigate, =q= to quit and even press =6= as a 277 | shortcut to select the 6th candidate. 278 | 279 | *** Roll your own 280 | 281 | See the documentation on variable [[sym:yas-prompt-functions][=yas-prompt-functions=]] 282 | -------------------------------------------------------------------------------- /src/yasnippet/doc/snippet-menu.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: YASnippet menu 4 | 5 | When [[sym:yas-minor-mode][=yas-minor-mode=]] is active, YASnippet will setup a menu just after 6 | the "Buffers" menu in the menubar. 7 | 8 | In this menu, you can find 9 | 10 | - The currently loaded snippet definitions, organized by major mode, 11 | and optional grouping. 12 | 13 | - A rundown of the most common commands, (followed by their 14 | keybindings) including commands to load directories and reload all 15 | snippet definitions. 16 | 17 | - A series of submenus for customizing and exploring YASnippet 18 | behavior. 19 | 20 | [[./images/menu-1.png]] 21 | 22 | * Loading snippets from menu 23 | 24 | Invoking "Load snippets..." from the menu invokes [[sym:yas-load-directory][=yas-load-directory=]] 25 | and prompts you for a snippet directory hierarchy to load. 26 | 27 | Also useful is the "Reload everything" item to invoke [[#yas-reload-all][=yas-reload-all=]] 28 | which uncondionally reloads all the snippets directories defined in 29 | [[sym:yas-snippet-dirs][=yas-snippet-dirs=]] and rebuilds the menus. 30 | 31 | * Snippet menu behavior 32 | 33 | YASnippet will list in this section all the loaded snippet definitions 34 | organized by snippet table name. 35 | 36 | You can use this section to explore currently loaded snippets. If you 37 | click on one of them, the default behavior is to expand it, 38 | unconditionally, inside the current buffer. 39 | 40 | You can however, customize variable [[sym:yas-visit-from-menu][=yas-visit-from-menu=]] to be =t= 41 | which will take you to the snippet definition file when you select it 42 | from the menu. 43 | 44 | If you want the menu show only snippet tables whose name corresponds to 45 | a "real" major mode. You do this by setting [[sym:yas-use-menu][=yas-use-menu=]] to 46 | '=real-modes=. 47 | 48 | Finally, to have the menu show only the tables for the currently active 49 | mode, set [[sym:yas-use-menu][=yas-use-menu=]] to =abbreviate=. 50 | 51 | These customizations can also be found in the menu itself, under the 52 | "Snippet menu behavior" submenu. 53 | 54 | * Controlling indenting 55 | 56 | The "Indenting" submenu contains options to control the values of 57 | [[sym:yas-indent-line][=yas-indent-line=]] and [[sym:yas-also-auto-indent-first-line][=yas-also-auto-indent-first-line=]]. See 58 | [[./snippet-development.org][Writing snippets]]. 59 | 60 | * Prompting method 61 | 62 | The "Prompting method" submenu contains options to control the value of 63 | [[sym:yas-prompt-functions][=yas-prompt-functions=]]. See [[./snippet-expansion.org][Expanding snippets]]. 64 | 65 | * Misc 66 | 67 | The "Misc" submenu contains options to control the values of more 68 | variables. 69 | -------------------------------------------------------------------------------- /src/yasnippet/doc/snippet-organization.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: Organizing snippets 4 | 5 | * Basic structure 6 | 7 | Snippet collections can be stored in plain text files. They are arranged by 8 | sub-directories naming *snippet tables*. These mostly name Emacs major names. 9 | 10 | #+begin_example 11 | . 12 | |-- c-mode 13 | | `-- printf 14 | |-- java-mode 15 | | `-- println 16 | `-- text-mode 17 | |-- email 18 | `-- time 19 | #+end_example 20 | 21 | The collections are loaded into *snippet tables* which the 22 | triggering mechanism (see [[file:snippet-expansion.org][Expanding Snippets]]) looks up and 23 | (hopefully) causes the right snippet to be expanded for you. 24 | 25 | * Setting up =yas-snippet-dirs= 26 | 27 | The emacs variable [[sym:yas-snippet-dirs][=yas-snippet-dirs=]] tells YASnippet 28 | which collections to consider. It's used when you activate 29 | [[sym:yas-global-mode][=yas-global-mode=]] or call 30 | [[sym:yas-reload-all][=yas-reload-all=]] interactively. 31 | 32 | The default considers: 33 | 34 | - a personal collection that lives in =~/.emacs.d/snippets= 35 | - the bundled collection, taken as a relative path to =yasnippet.el= localtion 36 | 37 | When you come across other snippet collections, do the following to try them 38 | out: 39 | 40 | #+begin_src emacs-lisp :exports code 41 | ;; Develop in ~/emacs.d/mysnippets, but also 42 | ;; try out snippets in ~/Downloads/interesting-snippets 43 | (setq yas-snippet-dirs '("~/emacs.d/mysnippets" 44 | "~/Downloads/interesting-snippets")) 45 | 46 | ;; OR, keeping YASnippet defaults try out ~/Downloads/interesting-snippets 47 | (setq yas-snippet-dirs (append yas-snippet-dirs 48 | '("~/Downloads/interesting-snippets"))) 49 | #+end_src 50 | 51 | Collections appearing earlier in the list override snippets with same names 52 | appearing in collections later in the list. [[sym:yas-new-snippet][=yas-new-snippet=]] always stores 53 | snippets in the first collection. 54 | 55 | * The =.yas-parents= file 56 | 57 | It's very useful to have certain modes share snippets between 58 | themselves. To do this, choose a mode subdirectory and place a 59 | =.yas-parents= containing a whitespace-separated list of other mode 60 | names. When you reload those modes become parents of the original 61 | mode. 62 | 63 | #+begin_example 64 | . 65 | |-- c-mode 66 | | |-- .yas-parents # contains "cc-mode text-mode" 67 | | `-- printf 68 | |-- cc-mode 69 | | |-- for 70 | | `-- while 71 | |-- java-mode 72 | | |-- .yas-parents # contains "cc-mode text-mode" 73 | | `-- println 74 | `-- text-mode 75 | |-- email 76 | `-- time 77 | #+end_example 78 | 79 | 80 | * TODO The =.yas-make-groups= file 81 | 82 | If you place an empty plain text file =.yas-make-groups= inside one 83 | of the mode directories, the names of these sub-directories are 84 | considered groups of snippets and [[snippet-menu.org][the menu]] is organized much more 85 | cleanly: 86 | 87 | [[./images/menu-groups.png]] 88 | 89 | Another way to achieve this is to place a =# group:= directive 90 | inside the snippet definition. See [[./snippet-development.org][Writing Snippets]]. 91 | 92 | #+begin_example 93 | $ tree ruby-mode/ 94 | ruby-mode/ 95 | |-- .yas-make-groups 96 | |-- collections 97 | | |-- each 98 | | `-- ... 99 | |-- control structure 100 | | |-- forin 101 | | `-- ... 102 | |-- definitions 103 | | `-- ... 104 | `-- general 105 | `-- ... 106 | #+end_example 107 | 108 | Yet another way to create a nice snippet menu is to write into 109 | =.yas-make-groups= a menu definition. TODO 110 | 111 | * The =.yas-setup.el= file 112 | 113 | If there is file named =.yas-setup.el= in a mode's snippet 114 | subdirectory, it is loaded along with the snippets. Utility 115 | functions used by the snippets can be put here. 116 | 117 | * The =.yas-compiled-snippet.el= file 118 | 119 | You may compile a top-level snippet directory with the 120 | =yas-compile-directory= function, which will create a 121 | =.yas-compiled-snippets.el= file under each mode subdirectory, 122 | which contains definitions for all snippets in the subdirectory. 123 | Compilation helps improve loading time. 124 | 125 | Alternatively, you may compile all directories in the list 126 | =yas-snippet-dirs= with the =yas-recompile-all= function. 127 | 128 | * The =.yas-skip= file 129 | 130 | A =.yas-skip= file in a mode's snippet subdirectory tells YASnippet 131 | not to load snippets from there. 132 | -------------------------------------------------------------------------------- /src/yasnippet/doc/snippet-reference.org: -------------------------------------------------------------------------------- 1 | #+SETUPFILE: org-setup.inc 2 | 3 | #+TITLE: Reference 4 | 5 | #+BEGIN_SRC emacs-lisp :exports results :results value raw 6 | (yas--document-symbols 1 `("Interactive functions" . ,#'interactive-form) 7 | `("Customization variables" . ,#'(lambda (sym) 8 | (and (boundp sym) 9 | (get sym 'standard-value)))) 10 | `("Useful functions" . ,#'fboundp) 11 | `("Useful variables" . ,#'boundp)) 12 | #+END_SRC 13 | -------------------------------------------------------------------------------- /src/yasnippet/doc/stylesheets/manual.css: -------------------------------------------------------------------------------- 1 | nav > ul > li.center > ul { 2 | padding: 0; 3 | } 4 | 5 | nav li { 6 | vertical-align: top; 7 | 8 | display: inline; 9 | list-style-type: none; 10 | padding: 0.5em; 11 | } 12 | 13 | nav > ul > li { 14 | display: inline-block; 15 | } 16 | 17 | /* match org's css for
 */
18 | code {
19 |     background-color: #F3F5F7;
20 |     font-family: courier, monospace;
21 | }
22 | 
23 | #content {
24 |     margin-left: 5%;
25 |     margin-right: 10%;
26 | }
27 | 
28 | /* Styles for htmlize.el fontification.  */
29 | 
30 | .org-comment        { color: #005000; }    /* font-lock-comment-face */
31 | .org-keyword        { font-weight: bold; } /* font-lock-keyword-face */
32 | .org-string         { color: #8b0000; }    /* font-lock-string-face */
33 | .org-warning        { color: #ff8c00;
34 |                       font-weight: bold; } /* warning */
35 | .org-warning-1      { color: #ff0000;
36 |                       font-weight: bold; } /* font-lock-warning-face */
37 | .org-preprocessor   { color: #483d8b; }    /* font-lock-preprocessor-face */
38 | .org-constant       { color: #008b8b; }    /* font-lock-constant-face */
39 | .org-function-name  { color: #0000ff; }    /* font-lock-function-name-face */
40 | .org-type           { color: #228b22; }    /* font-lock-type-face */
41 | .org-variable-name  { color: #a0522d; }    /* font-lock-variable-name-face */
42 | 
43 | .org-rst-adornment  { color: #a020f0; }            /* rst-adornment */
44 | .org-rst-block      { color: #a020f0; }            /* rst-block */
45 | .org-rst-comment    { color: #b22222; }            /* rst-comment */
46 | .org-rst-definition { color: #0000ff; }            /* rst-definition */
47 | .org-rst-directive  { color: #483d8b; }            /* rst-directive */
48 | .org-rst-emphasis1  { font-style: italic; }        /* rst-emphasis1 */
49 | .org-rst-emphasis2  { font-weight: bold; }         /* rst-emphasis2 */
50 | .org-rst-external   { color: #228b22; }            /* rst-external */
51 | .org-rst-level-1    { background-color: #d9d9d9; } /* rst-level-1 */
52 | .org-rst-level-2    { background-color: #c7c7c7; } /* rst-level-2 */
53 | .org-rst-level-3    { background-color: #b5b5b5; } /* rst-level-3 */
54 | .org-rst-level-4    { background-color: #a3a3a3; } /* rst-level-4 */
55 | .org-rst-level-5    { background-color: #919191; } /* rst-level-5 */
56 | .org-rst-level-6    { background-color: #7f7f7f; } /* rst-level-6 */
57 | .org-rst-literal    { color: #8b2252; }            /* rst-literal */
58 | .org-rst-reference  { color: #a0522d; }            /* rst-reference */
59 | .org-rst-transition { color: #a020f0; }            /* rst-transition */
60 | 


--------------------------------------------------------------------------------
/src/yasnippet/doc/stylesheets/styles.css:
--------------------------------------------------------------------------------
 1 | @media all
 2 | {
 3 |     body {
 4 |         margin: 1em auto;
 5 |         /*margin: 10px 18% 10px 18%;*/
 6 |         font-family: Arial;
 7 |         /*text-align: justify;*/
 8 |         font-size: 14pt;
 9 |         padding: 10px;
10 |         line-height: 1.2em;
11 |         max-width: 600pt;
12 |     }
13 | 
14 |     div#table-of-contents {
15 |         position: fixed;
16 |         left: 0%;
17 |         right: 0%;
18 |         top: 0px;
19 |         z-index: 100;
20 |         background: black;
21 |     }
22 | 
23 |     div#table-of-contents h2 {
24 |         display: none;
25 |     }
26 | 
27 |     div#table-of-contents a {
28 |         text-decoration: none;
29 |         color: white;
30 |     }
31 | 
32 |     div#table-of-contents a:visited {
33 |         color: white;
34 |     }
35 | 
36 |     div#table-of-contents a:hover {
37 |         color: orange;
38 |     }
39 | 
40 |     div.outline-2 h2{
41 |         padding-top: 50px;
42 |     }
43 | 
44 |     div#text-table-of-contents {
45 |         text-color: white;
46 |         text-align: center;
47 |         margin-left: 30%;
48 |         margin-right: 30%;
49 |     }
50 | 
51 |     div#text-table-of-contents ul {
52 |         height: 2em;
53 |         width: 500px;
54 |         list-style: none;
55 |         margin: auto;
56 |     }
57 | 
58 |     div#text-table-of-contents ul li {
59 |         float: left;
60 |         margin-left:auto;
61 |         margin-right: auto;
62 |         padding-left: 10px;
63 |     }
64 | 
65 |     div#postamble{
66 |         position: fixed;
67 |         width: 800px;
68 |         height: 250px;
69 |         left: 50%;
70 |         right: 50%;
71 |         margin:-75px 0 0 -400px;
72 |         bottom: -20px;
73 |         font-size: 10pt;
74 |         color: grey;
75 |         background: url('siscog-bottom-logo.png') no-repeat;
76 |         /* background-size: 100% 100%; */
77 |     }
78 | 
79 |     div#postamble *{
80 |         display: none;
81 |     }
82 | 
83 |     div#postamble p.date{
84 |         position: relative;
85 |         bottom: -200px;
86 |         text-align: center;
87 |         display: block;
88 |     }
89 | 
90 | 
91 | 
92 | 
93 | }


--------------------------------------------------------------------------------
/src/yasnippet/doc/yas-doc-helper.el:
--------------------------------------------------------------------------------
  1 | ;;; yas-doc-helper.el --- Help generate documentation for YASnippet
  2 | 
  3 | ;; Copyright (C) 2012, 2013  Free Software Foundation, Inc.
  4 | 
  5 | ;; Author: João Távora 
  6 | ;; Keywords: convenience
  7 | 
  8 | ;; This program is free software; you can redistribute it and/or modify
  9 | ;; it under the terms of the GNU General Public License as published by
 10 | ;; the Free Software Foundation, either version 3 of the License, or
 11 | ;; (at your option) any later version.
 12 | 
 13 | ;; This program is distributed in the hope that it will be useful,
 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 | ;; GNU General Public License for more details.
 17 | 
 18 | ;; You should have received a copy of the GNU General Public License
 19 | ;; along with this program.  If not, see .
 20 | 
 21 | ;;; Commentary:
 22 | 
 23 | ;; Some functions to help generate YASnippet docs
 24 | 
 25 | ;;; Code:
 26 | 
 27 | (eval-when-compile
 28 |   (require 'cl))
 29 | (require 'org)
 30 | (or (require 'org-publish nil t)
 31 |     (require 'ox-publish))
 32 | (require 'yasnippet) ; docstrings must be loaded
 33 | 
 34 | (defun yas--org-raw-html (tag content)
 35 |   ;; in version 8.0 org-mode changed the export syntax, see
 36 |   ;; http://orgmode.org/worg/org-8.0.html#sec-8-1
 37 |   (format (if (version< org-version "8.0.0")
 38 |               "@<%s>%s@"                ; old: @
 39 |             "@@html:<%s>@@%s@@html:@@") ; new: @@html:@@
 40 |           tag content tag))
 41 | 
 42 | (defun yas--document-symbol (symbol level)
 43 |   (let* ((stars (make-string level ?*))
 44 |          (args (and (fboundp symbol)
 45 |                     (mapcar #'symbol-name (help-function-arglist symbol t))))
 46 |          (heading (cond ((fboundp symbol)
 47 |                          (format
 48 |                           "%s =%s= (%s)" stars symbol
 49 |                           (mapconcat (lambda (a)
 50 |                                        (format (if (string-prefix-p "&" a)
 51 |                                                    "/%s/" "=%s=") a))
 52 |                                      args " ")))
 53 |                         (t
 54 |                          (format "%s =%s=\n" stars symbol))))
 55 |          (after-heading (format ":PROPERTIES:\n:CUSTOM_ID: %s\n:END:" symbol))
 56 |          (body (or (cond ((fboundp symbol)
 57 |                           (let ((doc-synth (car-safe (get symbol 'function-documentation))))
 58 |                             (if (functionp doc-synth)
 59 |                                 (funcall doc-synth nil)
 60 |                               (documentation symbol t))))
 61 |                          ((boundp symbol)
 62 |                           (documentation-property symbol 'variable-documentation t))
 63 |                          (t
 64 |                           (format "*WARNING*: no symbol named =%s=" symbol)))
 65 |                    (format "*WARNING*: no doc for symbol =%s=" symbol)))
 66 |          (case-fold-search nil))
 67 |     ;; do some transformations on the body:
 68 |     ;; ARGxxx becomes @arg@xxx
 69 |     ;; FOO becomes /foo/
 70 |     ;; `bar' becomes [[#bar][=bar=]]
 71 |     (setq body (replace-regexp-in-string
 72 |                 "\\<\\([A-Z][-A-Z0-9]+\\)\\(\\sw+\\)?\\>"
 73 |                 #'(lambda (match)
 74 |                     (let* ((match1 (match-string 1 match))
 75 |                            (prefix (downcase match1))
 76 |                            (suffix (match-string 2 match))
 77 |                            (fmt (cond
 78 |                                  ((member prefix args)
 79 |                                   (yas--org-raw-html "code" "%s"))
 80 |                                  ((null suffix) "/%s/"))))
 81 |                       (if fmt (format fmt prefix)
 82 |                         match1)))
 83 |                 body t t 1)
 84 |           body (replace-regexp-in-string
 85 |                 "`\\([a-z-]+\\)'"
 86 |                 #'(lambda (match)
 87 |                     (let* ((name (downcase (match-string 1 match)))
 88 |                            (sym (intern name)))
 89 |                       (if (memq sym yas--exported-syms)
 90 |                           (format "[[#%s][=%s=]]" name name)
 91 |                         (format "=%s=" name))))
 92 |                 body t))
 93 |     ;; output the paragraph
 94 |     (concat heading "\n" after-heading "\n" body)))
 95 | 
 96 | (defun yas--document-symbols (level &rest names-and-predicates)
 97 |   (let ((sym-lists (make-vector (length names-and-predicates) nil))
 98 |         (stars (make-string level ?*)))
 99 |     (loop for sym in yas--exported-syms
100 |           do (loop for test in (mapcar #'cdr names-and-predicates)
101 |                    for i from 0
102 |                    do (when (funcall test sym)
103 |                         (push sym (aref sym-lists i))
104 |                         (return))))
105 |     (loop for slist across sym-lists
106 |           for name in (mapcar #'car names-and-predicates)
107 |           concat (format "\n%s %s\n" stars name)
108 |           concat (mapconcat (lambda (sym)
109 |                               (yas--document-symbol sym (1+ level)))
110 |                             slist "\n\n"))))
111 | 
112 | (defun yas--internal-link-snippet ()
113 |   (interactive)
114 |   (yas-expand-snippet "[[#$1][=${1:`yas/selected-text`}=]]"))
115 | 
116 | (define-key org-mode-map [M-f8] 'yas--internal-link-snippet)
117 | 
118 | ;; This lets all the org files be exported to HTML with
119 | ;; `org-publish-current-project' (C-c C-e P).
120 | 
121 | (let* ((dir (if load-file-name (file-name-directory load-file-name)
122 |               default-directory))
123 |        (src-epoch (getenv "SOURCE_DATE_EPOCH"))
124 |        ;; Presence of SOURCE_DATE_EPOCH indicates a reproducible
125 |        ;; build, don't depend on git.
126 |        (rev (unless src-epoch
127 |               (ignore-errors
128 |                 (car (process-lines "git" "describe" "--dirty")))))
129 |        (date (format-time-string
130 |               "(%Y-%m-%d %H:%M:%S)"
131 |               (seconds-to-time
132 |                (string-to-number
133 |                 (or (if rev (car (process-lines "git" "show" "--format=%ct"))
134 |                       src-epoch)
135 |                     "0")))
136 |               t))
137 |        (proj-plist
138 |         `(,@(when (fboundp 'org-html-publish-to-html)
139 |               '(:publishing-function org-html-publish-to-html))
140 |           :base-directory ,dir :publishing-directory ,dir
141 |           :html-preamble
142 |           ,(with-temp-buffer
143 |              (insert-file-contents (expand-file-name "nav-menu.html.inc" dir))
144 |              (buffer-string))
145 |           :html-postamble
146 |           ,(concat "

Generated by %c from " 147 | (or rev yas--version) " " date "

\n" 148 | "

%v

\n"))) 149 | (project (assoc "yasnippet" org-publish-project-alist))) 150 | (when rev ;; Rakefile :doc:upload uses "html-revision". 151 | (with-temp-file (expand-file-name "html-revision" dir) 152 | (princ rev (current-buffer)))) 153 | (if project 154 | (setcdr project proj-plist) 155 | (push `("yasnippet" . ,proj-plist) 156 | org-publish-project-alist))) 157 | 158 | (defun yas--generate-html-batch () 159 | (let ((org-publish-use-timestamps-flag nil) 160 | (org-export-copy-to-kill-ring nil) 161 | (org-confirm-babel-evaluate nil) 162 | (make-backup-files nil) 163 | (org-html-htmlize-output-type 'css)) 164 | (org-publish "yasnippet" 'force))) 165 | 166 | 167 | 168 | (provide 'yas-doc-helper) 169 | ;; Local Variables: 170 | ;; indent-tabs-mode: nil 171 | ;; coding: utf-8 172 | ;; End: 173 | ;;; yas-doc-helper.el ends here 174 | -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/A: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/ASCII: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/BLD^DIALOG: -------------------------------------------------------------------------------- 1 | ${1:DIALOG NUMBER},.${2:TEXT_PARAM},.${3:OUTPUT_PARAM},${4:OUTPUT_ARRAY},"${5:FLAGS$(yas/choose-value '("S" "F" "SF"))}" -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/C: -------------------------------------------------------------------------------- 1 | ${1:CHARACTER CODE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/CHAR: -------------------------------------------------------------------------------- 1 | ${1:CHARACTER CODE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/CHK^DIE: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},${3:FLAGS$(yas/choose-value '("H" "E" "HE"))},${4:VALUE},.${5:RESULT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/CLEAN^DILF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/snippets/mumps-mode/CLEAN^DILF -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/CREF^DILF: -------------------------------------------------------------------------------- 1 | ${1:OPEN_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/CREIXN^DDMOD: -------------------------------------------------------------------------------- 1 | .${1:XREF},"${2:FLAGS$(yas/choose-value '("S" "W" "SW"))}",${3:.RESULT},"${4:OUTPUT_ROOT}","${5:MSG_ROOT}" -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/D: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/DATA: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/DA^DILF: -------------------------------------------------------------------------------- 1 | ${1:IENS},.${2:DA} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/DELIXN^DDMOD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:INDEX},"${3:FLAGS$(yas/choose-value '("K" "W"))}",${4:OUTPUT_ROOT},${5:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/DELIX^DDMOD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},${3:CROSS_REF},"${4:FLAGS$(yas/choose-value '("K" "W"))}",${5:OUTPUT_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/DT^DILF: -------------------------------------------------------------------------------- 1 | ${1:FLAGS},${2:IN_DATE},.${3:RESULT},${4:LIMIT},${5:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/E: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:STARTING POSITION},${3:ENDING POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/EXTERNAL^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},"${3:FLAGS$(yas/choose-value '("F" "L" "U"))}",${4:INTERNAL},${5:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/EXTRACT: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:STARTING POSITION},${3:ENDING POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/EZBLD^DIALOG: -------------------------------------------------------------------------------- 1 | ${1:DIALOG_NUMBER},.${2:TEXT_PARAM} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/F: -------------------------------------------------------------------------------- 1 | ${1:SEARCH SOURCE},${2:SEARCH TERM},${3:STARTING POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FDA^DILF: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},${4:FLAGS},${5:VALUE},${6:FDA_ROOT},${7:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FIELDLST^DID: -------------------------------------------------------------------------------- 1 | ${1:TARGET_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FIELD^DID: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},"${3:FLAGS$(yas/choose-value '("N" "Z" "NZ"))},${4:ATTRIBUTES},${5:TARGET_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FILELST^DID: -------------------------------------------------------------------------------- 1 | ${1:TARGET_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FILESEC^DDMOD: -------------------------------------------------------------------------------- 1 | ${1:FILE},.${2:SECURITY_CODES},${3:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FILE^DID: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FLAGS$(yas/choose-value '("N" "Z" "NZ"))},${3:ATTRIBUTES},${4:TARGET_ROOT},${5:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FILE^DIE: -------------------------------------------------------------------------------- 1 | ${1:FLAGS$(yas/choose-value '("E" "K" "S" "T" "U"))},${2:FDA_ROOT},${3:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FIND: -------------------------------------------------------------------------------- 1 | ${1:SEARCH SOURCE},${2:SEARCH TERM},${3:STARTING POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FIND1^DIC: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FLAGS},.${4:VALUE},.${5:INDEXES},.${6:SCREEN},${7:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FIND^DIC: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELDS},"${4:FLAGS}",.${5:VALUE},${6:NUMBER},.${7:INDEXES},.${8:SCREEN},${9:IDENTIFIER},${10:TARGET_ROOT},${11:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FLDNUM^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELDNAME} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FN: -------------------------------------------------------------------------------- 1 | ${1:VALUE},${2:FORMAT},${3:ROUND TO PLACES} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/FNUMBER: -------------------------------------------------------------------------------- 1 | ${1:VALUE},${2:FORMAT},${3:ROUND TO PLACES} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/G: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:DEFAULT VALUE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/GET: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:DEFAULT VALUE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/GET1^DID: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},${3:FLAGS$(yas/choose-value '("Z"))},${4:ATTRIBUTE},${5:TARGET_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/GET1^DIQ: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},"${4:FLAGS$(yas/choose-value '("I" "Z" "A#"))}",${5:TARGET_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/GETS^DIQ: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},"${4:FLAGS$(yas/choose-value '("E" "I" "N" "R" "Z"))}",${5:TARGET_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/HELP^DIE: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},"${4:FLAGS$(yas/choose-value '("?" "??" "A" "B" "C" "D" "F" "G" "H" "M" "P" "S" "T" "U" "V" "X"))}",${5:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/HTML^DILF: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:ACTION$(yas/choose-value '("1" "-1"))} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/IENS^DILF: -------------------------------------------------------------------------------- 1 | .${1:DA} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/J: -------------------------------------------------------------------------------- 1 | ${1:VALUE},${2:WIDTH},${3:ROUND TO PLACES} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/JUSTIFY: -------------------------------------------------------------------------------- 1 | ${1:VALUE},${2:WIDTH},${3:ROUND TO PLACES} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/KEYVAL^DIE: -------------------------------------------------------------------------------- 1 | "${1:FLAGS}",${2:FDA_ROOT},${3:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/L: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:DELIMITER} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/LENGTH: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:DELIMITER} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/LIST^DIC: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELDS},"${4:FLAGS$(yas/choose-value '("B" "I" "K" "M" "P" "Q" "U"))}",${5:NUMBER},.${6:FROM},.${7:PART},${8:INDEX},.${9:SCREEN},${10:IDENTIFIER},${11:TARGET_ROOT},${12:MESSAGE_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/MSG^DIALOG: -------------------------------------------------------------------------------- 1 | "${1:FLAGS$(yas/choose-value '("A" "W" "S" "E" "H" "M" "B" "T"))}",.${2:OUTPUT_ARRAY},${3:TEXT_WIDTH},${4:LEFT_MARGIN},${5:INPUT_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/NA: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:INTEGER SUBSCRIPT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/NAME: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:INTEGER SUBSCRIPT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/O: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:DIRECTION$(yas/choose-value '(1 -1))} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/ORDER: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:DIRECTION$(yas/choose-value '(1 -1))} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/OREF^DILF: -------------------------------------------------------------------------------- 1 | ${1:CLOSED_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/P: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:DELIMITER},${3:START POSITION},${4:END POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/PIECE: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:DELIMITER},${3:START POSITION},${4:END POSITION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/PRD^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:DATA} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/Q: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/QL: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/QLENGTH: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/QS: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:SUBSCRIPT INDEX} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/QSUBSCRIPT: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE},${2:SUBSCRIPT INDEX} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/QUERY: -------------------------------------------------------------------------------- 1 | ${1:VARIABLE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/R: -------------------------------------------------------------------------------- 1 | ${1:MAX VALUE - 1} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/RANDOM: -------------------------------------------------------------------------------- 1 | ${1:MAX VALUE - 1} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/RECALL^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:USER} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/REVERSE: -------------------------------------------------------------------------------- 1 | ${1:STRING} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/ROOT^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FLAGS},${4:ERROR_FLAG} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/S: -------------------------------------------------------------------------------- 1 | ${1:CASE}:${2:VALUE},... -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/SACHEADER: -------------------------------------------------------------------------------- 1 | ${1:ROUTINE_NAME} ;${2:SITE}/${3:USER} - ${4:ROUTINE_DESCRIPTION};${5:DATE} 2 | ;;${6:VERSION};${7:PACKAGE_NAME};**${8:PATCHES}**;${9:VERSION_DATE};Build ${10:BUILD_NUMBER} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/SELECT: -------------------------------------------------------------------------------- 1 | ${1:CASE}:${2:VALUE},... -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/ST: -------------------------------------------------------------------------------- 1 | ${1:LEVEL},${2:MODE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/STACK: -------------------------------------------------------------------------------- 1 | ${1:LEVEL},${2:MODE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/T: -------------------------------------------------------------------------------- 1 | ${1:LOCATION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/TEXT: -------------------------------------------------------------------------------- 1 | ${1:LOCATION} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/TR: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:SEARCH TEXT},${3:REPLACEMENT TEXT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/TRANSLATE: -------------------------------------------------------------------------------- 1 | ${1:STRING},${2:SEARCH TEXT},${3:REPLACEMENT TEXT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/UPDATE^DIE: -------------------------------------------------------------------------------- 1 | "${1:FLAGS$(yas/choose-value '("E" "K" "S" "U"))}",${2:FDA_ROOT},${3:IEN_ROOT},${4:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VALS^DIE: -------------------------------------------------------------------------------- 1 | ${1:FLAGS},${2:FDA_EXT_ROOT},${3:FDA_INT_ROOT},${4:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VALUE1^DILF: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},${3:FDA_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VALUES^DILF: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD},${3:FDA_ROOT},.${4:RESULT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VAL^DIE: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},"${4:FLAGS$(yas/choose-value '("E" "F" "H" "R" "U"))}",${5:VALUE},.${6:RESULT},${7:FDA_ROOT},${8:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VFIELD^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:FIELD} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/VFILE^DILFD: -------------------------------------------------------------------------------- 1 | ${1:FILE} -------------------------------------------------------------------------------- /src/yasnippet/snippets/mumps-mode/WP^DIE: -------------------------------------------------------------------------------- 1 | ${1:FILE},${2:IENS},${3:FIELD},"${4:FLAGS$(yas/choose-value '("A" "K" "AK"))}",${5:WP_ROOT},${6:MSG_ROOT} -------------------------------------------------------------------------------- /src/yasnippet/yasnippet-debug.el: -------------------------------------------------------------------------------- 1 | ;;; yasnippet-debug.el --- debug functions for yasnippet -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2010, 2013, 2014, 2017 Free Software Foundation, Inc. 4 | 5 | ;; Author: João Távora 6 | ;; Keywords: emulations, convenience 7 | 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program. If not, see . 20 | 21 | ;;; Commentary: 22 | 23 | ;; Some debug functions. When loaded from the command line, provides 24 | ;; quick way to test out snippets in a fresh Emacs instance. 25 | ;; 26 | ;; emacs -Q -l yasnippet-debug [-v[v]] 27 | ;; [-M:] [-M.] [-S:[]] 28 | ;; [-- ...] 29 | ;; 30 | ;; See the source in `yas-debug-process-command-line' for meaning of 31 | ;; args. 32 | ;; 33 | ;;; Code: 34 | 35 | (defconst yas--loaddir 36 | (file-name-directory (or load-file-name buffer-file-name)) 37 | "Directory that yasnippet was loaded from.") 38 | 39 | (require 'yasnippet (if (boundp 'yas--loaddir) 40 | ;; Don't require '-L ' when debugging. 41 | (expand-file-name "yasnippet" yas--loaddir))) 42 | (require 'cl-lib) 43 | (eval-when-compile 44 | (unless (fboundp 'cl-flet) 45 | (defalias 'cl-flet 'flet))) 46 | (require 'color nil t) 47 | (require 'edebug) 48 | (eval-when-compile 49 | (require 'subr-x nil t) 50 | (cond ((fboundp 'when-let*) nil) ; Introduced in 26. 51 | ((fboundp 'when-let) ; Introduced in 25.1, 52 | (defalias 'when-let* 'when-let)) ; deprecated in 26. 53 | (t (defmacro when-let* (key-vals &rest body) 54 | (declare (indent 1) (debug ((symbolp form) body))) 55 | (let ((key-val (pop key-vals))) 56 | (if key-val 57 | `(let ((,(car key-val) ,(cadr key-val))) 58 | (if ,(car key-val) 59 | (when-let* ,key-vals 60 | ,@body))) 61 | `(progn ,@body))))))) 62 | 63 | (defvar yas-debug-live-indicators 64 | (make-hash-table :test #'eq)) 65 | 66 | (defun yas-debug-live-colors () 67 | (let ((colors ())) 68 | (maphash (lambda (_k v) (push (nth 1 (car v)) colors)) yas-debug-live-indicators) 69 | colors)) 70 | 71 | (defvar yas-debug-recently-live-indicators) 72 | 73 | (defun yas-debug-get-live-indicator (location) 74 | (require 'color) 75 | (when (boundp 'yas-debug-recently-live-indicators) 76 | (push location yas-debug-recently-live-indicators)) 77 | (let (beg end) 78 | (if (markerp location) 79 | (setq beg (setq end (marker-position location))) 80 | (setq beg (yas-debug-ov-fom-start location) 81 | end (yas-debug-ov-fom-end location))) 82 | (or (when-let* ((color-ov (gethash location yas-debug-live-indicators))) 83 | (if (and beg end) (move-overlay (cdr color-ov) beg end) 84 | (delete-overlay (cdr color-ov))) 85 | color-ov) 86 | (let* ((live-colors (yas-debug-live-colors)) 87 | (color 88 | (cl-loop with best-color = nil with max-dist = -1 89 | for color = (format "#%06X" (random #x1000000)) 90 | for comp = (if (fboundp 'color-complement) 91 | (apply #'color-rgb-to-hex (color-complement color)) 92 | color) 93 | if (< (color-distance color (face-foreground 'default)) 94 | (color-distance comp (face-foreground 'default))) 95 | do (setq color comp) 96 | for dist = (cl-loop for c in live-colors 97 | minimize (color-distance c color)) 98 | if (or (not live-colors) (> dist max-dist)) 99 | do (setq best-color color) (setq max-dist dist) 100 | repeat (if live-colors 100 1) 101 | finally return `(:background ,best-color))) 102 | (ov (make-overlay beg end))) 103 | (if (markerp location) 104 | (overlay-put ov 'before-string (propertize "↓" 'face color)) 105 | (overlay-put ov 'before-string (propertize "↘" 'face color)) 106 | (overlay-put ov 'after-string (propertize "↙" 'face color))) 107 | (puthash location (cons color ov) yas-debug-live-indicators))))) 108 | 109 | (defun yas-debug-live-marker (marker) 110 | (let* ((color-ov (yas-debug-get-live-indicator marker)) 111 | (color (car color-ov)) 112 | (ov (cdr color-ov)) 113 | (decorator (overlay-get ov 'before-string)) 114 | (str (format "at %d" (+ marker)))) 115 | (if (markerp marker) 116 | (propertize str 117 | 'cursor-sensor-functions 118 | `(,(lambda (_window _oldpos dir) 119 | (overlay-put 120 | ov 'before-string 121 | (propertize decorator 122 | 'face (if (eq dir 'entered) 123 | 'mode-line-highlight color))))) 124 | 'face color) 125 | str))) 126 | 127 | (defun yas-debug-ov-fom-start (ovfom) 128 | (cond ((overlayp ovfom) (overlay-start ovfom)) 129 | ((integerp ovfom) ovfom) 130 | (t (yas--fom-start ovfom)))) 131 | (defun yas-debug-ov-fom-end (ovfom) 132 | (cond ((overlayp ovfom) (overlay-end ovfom)) 133 | ((integerp ovfom) ovfom) 134 | (t (yas--fom-end ovfom)))) 135 | 136 | (defun yas-debug-live-range (range) 137 | (let* ((color-ov (yas-debug-get-live-indicator range)) 138 | (color (car color-ov)) 139 | (ov (cdr color-ov)) 140 | (decorator-beg (overlay-get ov 'before-string)) 141 | (decorator-end (overlay-get ov 'after-string)) 142 | (beg (yas-debug-ov-fom-start range)) 143 | (end (yas-debug-ov-fom-end range))) 144 | (if (and beg end (not (integerp beg)) (not (integerp end))) 145 | (propertize (format "from %d to %d" (+ beg) (+ end)) 146 | 'cursor-sensor-functions 147 | `(,(lambda (_window _oldpos dir) 148 | (let ((face (if (eq dir 'entered) 149 | 'mode-line-highlight color))) 150 | (overlay-put ov 'before-string 151 | (propertize decorator-beg 'face face)) 152 | (overlay-put ov 'after-string 153 | (propertize decorator-end 'face face))))) 154 | 'face color) 155 | ""))) 156 | 157 | (defmacro yas-debug-with-tracebuf (outbuf &rest body) 158 | (declare (indent 1)) 159 | (let ((tracebuf-var (make-symbol "tracebuf"))) 160 | `(let ((,tracebuf-var (or ,outbuf (get-buffer-create "*YASnippet trace*")))) 161 | (unless (eq ,tracebuf-var (current-buffer)) 162 | (cl-flet ((printf (fmt &rest args) 163 | (with-current-buffer ,tracebuf-var 164 | (insert (apply #'format fmt args))))) 165 | (unless ,outbuf 166 | (with-current-buffer ,tracebuf-var 167 | (erase-buffer) 168 | (when (fboundp 'cursor-sensor-mode) 169 | (cursor-sensor-mode +1)) 170 | (setq truncate-lines t))) 171 | (setq ,outbuf ,tracebuf-var) 172 | (save-restriction 173 | (widen) 174 | ,@body)))))) 175 | 176 | 177 | (defun yas-debug-snippet (snippet &optional outbuf) 178 | (yas-debug-with-tracebuf outbuf 179 | (when-let* ((overlay (yas--snippet-control-overlay snippet))) 180 | (printf "\tsid: %d control overlay %s\n" 181 | (yas--snippet-id snippet) 182 | (yas-debug-live-range overlay))) 183 | (when-let* ((active-field (yas--snippet-active-field snippet))) 184 | (unless (consp (yas--field-start active-field)) 185 | (printf "\tactive field: #%d %s %s covering \"%s\"\n" 186 | (or (yas--field-number active-field) -1) 187 | (if (yas--field-modified-p active-field) "**" "--") 188 | (yas-debug-live-range active-field) 189 | (buffer-substring-no-properties (yas--field-start active-field) (yas--field-end active-field))))) 190 | (when-let* ((exit (yas--snippet-exit snippet))) 191 | (printf "\tsnippet-exit: %s next: %s\n" 192 | (yas-debug-live-marker (yas--exit-marker exit)) 193 | (yas--exit-next exit))) 194 | (dolist (field (yas--snippet-fields snippet)) 195 | (unless (consp (yas--field-start field)) 196 | (printf "\tfield: %d %s %s covering \"%s\" next: %s%s\n" 197 | (or (yas--field-number field) -1) 198 | (if (yas--field-modified-p field) "**" "--") 199 | (yas-debug-live-range field) 200 | (buffer-substring-no-properties (yas--field-start field) (yas--field-end field)) 201 | (yas--debug-format-fom-concise (yas--field-next field)) 202 | (if (yas--field-parent-field field) 203 | (format " parent: %s" 204 | (yas--debug-format-fom-concise 205 | (yas--field-parent-field field))) 206 | ""))) 207 | (dolist (mirror (yas--field-mirrors field)) 208 | (unless (consp (yas--mirror-start mirror)) 209 | (printf "\t\tmirror: %s covering \"%s\" next: %s\n" 210 | (yas-debug-live-range mirror) 211 | (buffer-substring-no-properties (yas--mirror-start mirror) (yas--mirror-end mirror)) 212 | (yas--debug-format-fom-concise (yas--mirror-next mirror)))))))) 213 | 214 | (defvar yas-debug-target-buffer nil) 215 | (defvar yas-debug-target-snippets nil nil) 216 | (make-variable-buffer-local 'yas-debug-target-snippets) 217 | 218 | (defvar yas-debug-undo nil) 219 | 220 | (defun yas-toggle-debug-undo (value) 221 | (interactive (list (not yas-debug-undo))) 222 | (setq yas-debug-undo value) 223 | (yas--message 3 "debug undo %sabled" (if yas-debug-undo "en" "dis"))) 224 | 225 | (defadvice yas--snippet-parse-create (before yas-debug-target-snippet (snippet)) 226 | (add-to-list 'yas-debug-target-snippets snippet)) 227 | 228 | (defadvice yas--commit-snippet (after yas-debug-untarget-snippet (snippet)) 229 | (setq yas-debug-target-snippets 230 | (remq snippet yas-debug-target-snippets)) 231 | (maphash (lambda (k color-ov) 232 | (delete-overlay (cdr color-ov))) 233 | yas-debug-live-indicators) 234 | (clrhash yas-debug-live-indicators)) 235 | 236 | (defun yas-debug-snippets (&optional outbuf hook) 237 | "Print debug information on active snippets to buffer OUTBUF. 238 | If OUTBUF is nil, use a buffer named \"*YASsnippet trace*\". 239 | If HOOK is non-nil, install `yas-debug-snippets' in 240 | `post-command-hook' to update the information on every command 241 | after this one. If it is `snippet-navigation' then install hook 242 | buffer-locally, otherwise install it globally. If HOOK is 243 | `edebug-create', also instrument the function 244 | `yas--snippet-parse-create' with `edebug' and show its source." 245 | (interactive (list nil t)) 246 | (condition-case err 247 | (yas-debug-with-tracebuf outbuf 248 | (unless (buffer-live-p yas-debug-target-buffer) 249 | (setq yas-debug-target-buffer nil)) 250 | (with-current-buffer (or yas-debug-target-buffer (current-buffer)) 251 | (when yas-debug-target-snippets 252 | (setq yas-debug-target-snippets 253 | (cl-delete-if-not #'yas--snippet-p yas-debug-target-snippets))) 254 | (let ((yas-debug-recently-live-indicators nil)) 255 | (dolist (snippet (or yas-debug-target-snippets 256 | (yas-active-snippets))) 257 | (printf "snippet %d\n" (yas--snippet-id snippet)) 258 | (yas-debug-snippet snippet outbuf)) 259 | (maphash (lambda (loc color-ov) 260 | (unless (memq loc yas-debug-recently-live-indicators) 261 | (delete-overlay (cdr color-ov)) 262 | (remhash loc yas-debug-live-indicators))) 263 | yas-debug-live-indicators)) 264 | (when (and yas-debug-undo (listp buffer-undo-list)) 265 | (printf "Undo list has %s elements:\n" (length buffer-undo-list)) 266 | (cl-loop for undo-elem in buffer-undo-list 267 | do (printf "%S\n" undo-elem)))) 268 | (when hook 269 | (setq yas-debug-target-buffer (current-buffer)) 270 | (ad-enable-advice 'yas--snippet-parse-create 'before 'yas-debug-target-snippet) 271 | (ad-activate 'yas--snippet-parse-create) 272 | (ad-enable-advice 'yas--commit-snippet 'after 'yas-debug-untarget-snippet) 273 | (ad-activate 'yas--commit-snippet) 274 | (add-hook 'post-command-hook #'yas-debug-snippets 275 | nil (eq hook 'snippet-navigation)) 276 | ;; Window management is slapped together, it does what I 277 | ;; want when the caller has a single window open. Good 278 | ;; enough for now. 279 | (when (eq hook 'edebug-create) 280 | (edebug-instrument-function 'yas--snippet-parse-create) 281 | (let ((buf-point (find-function-noselect 'yas--snippet-parse-create))) 282 | (with-current-buffer (car buf-point) 283 | (goto-char (cdr buf-point))))) 284 | outbuf)) 285 | ((debug error) (signal (car err) (cdr err))))) 286 | 287 | (defun yas-debug-snippet-create () 288 | (yas-debug-snippets nil 'create)) 289 | 290 | (defun yas--debug-format-fom-concise (fom) 291 | (when fom 292 | (cond ((yas--field-p fom) 293 | (format "field %s from %d to %d" 294 | (yas--field-number fom) 295 | (+ (yas--field-start fom)) 296 | (+ (yas--field-end fom)))) 297 | ((yas--mirror-p fom) 298 | (format "mirror from %d to %d" 299 | (+ (yas--mirror-start fom)) 300 | (+ (yas--mirror-end fom)))) 301 | (t 302 | (format "snippet exit at %d" 303 | (+ (yas--fom-start fom))))))) 304 | 305 | (defun yas-debug-process-command-line (&optional options) 306 | "Implement command line processing." 307 | (setq yas-verbosity 99) 308 | (setq yas-triggers-in-field t) 309 | (setq debug-on-error t) 310 | (let* ((snippet-mode 'fundamental-mode) 311 | (snippet-key nil)) 312 | (unless options 313 | (setq options (cl-loop for opt = (pop command-line-args-left) 314 | while (and opt (not (equal opt "--")) 315 | (string-prefix-p "-" opt)) 316 | collect opt))) 317 | (when-let* ((mode (cl-member "-M:" options :test #'string-prefix-p))) 318 | (setq snippet-mode (intern (concat (substring (car mode) 3) "-mode")))) 319 | (when-let* ((mode (cl-member "-M." options :test #'string-prefix-p))) 320 | (setq snippet-mode 321 | (cdr (cl-assoc (substring (car mode) 2) auto-mode-alist 322 | :test (lambda (ext regexp) (string-match-p regexp ext)))))) 323 | (switch-to-buffer (get-buffer-create "*yas test*")) 324 | (funcall snippet-mode) 325 | (when-let* ((snippet-file (cl-member "-S:" options :test #'string-prefix-p))) 326 | (setq snippet-file (substring (car snippet-file) 3)) 327 | (if (file-exists-p snippet-file) 328 | (with-temp-buffer 329 | (insert-file-contents snippet-file) 330 | (let ((snippet-deflist (yas--parse-template snippet-file))) 331 | (yas-define-snippets snippet-mode (list snippet-deflist)) 332 | (setq snippet-key (car snippet-deflist)))) 333 | (yas-reload-all) 334 | (let ((template (yas--lookup-snippet-1 snippet-file snippet-mode))) 335 | (if template 336 | (setq snippet-key (yas--template-key template)) 337 | (error "No such snippet `%s'" snippet-file))))) 338 | (display-buffer (find-file-noselect 339 | (expand-file-name "yasnippet.el" yas--loaddir))) 340 | (when-let* ((verbosity (car (or (member "-v" options) (member "-vv" options))))) 341 | (set-window-buffer 342 | (split-window) (yas-debug-snippets 343 | nil (if (equal verbosity "-vv") 'edebug-create t)))) 344 | (yas-minor-mode +1) 345 | (when snippet-key (insert snippet-key)))) 346 | 347 | (when command-line-args-left 348 | (yas-debug-process-command-line)) 349 | 350 | (provide 'yasnippet-debug) 351 | ;; Local Variables: 352 | ;; indent-tabs-mode: nil 353 | ;; autoload-compute-prefixes: nil 354 | ;; End: 355 | ;;; yasnippet-debug.el ends here 356 | -------------------------------------------------------------------------------- /src/yasnippet/yasnippet-tests.el: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoherentLogic/lorikeem/3290298b38171429c4ce4af6f3f0c9fd81676709/src/yasnippet/yasnippet-tests.el --------------------------------------------------------------------------------