MicroEmacs / PlpgSQLMode

Motivation

Editing large chunks of plpgsql code can be a pain if you are hunting for your procedure and function definitions.

Add the following lines to your own file mysql.emf which should be in our personal microemacs/user directory:

set-variable .fhook-sql.collapse-open  "\\$\\$$"
set-variable .fhook-sql.collapse-close "^\\$\\$"
set-variable .fhook-sql.collapse-mclose "1"
set-variable .fhook-sql.collapse-mnext "-1"
buffer-bind-key "collapse-current" "f2"
buffer-bind-key "collapse-all" "f3"
set-variable .fhook-sql.item-list-s1 "^CREATE .+FUNCTION[\t ]+\\([A-Za-z0-9_]*\\)[\t ]*"
set-variable .fhook-sql.item-list-r1 "Func \ecB\\1\ecA"
set-variable .fhook-sql.item-list-s2 "^CREATE .+VIEW[\t ]+\\([A-Za-z0-9_]*\\)[\t ]*"
set-variable .fhook-sql.item-list-r2 "View \ecB\\1\ecA"
set-variable .fhook-sql.item-list-s3 "^CREATE +TYPE[\t ]+\\([A-Za-z0-9_]*\\)[\t ]*"
set-variable .fhook-sql.item-list-r3 "Type \ecB\\1\ecA"
hilight .hilight.sql 1 "replace"               .scheme.keyword
hilight .hilight.sql 1 "returns"               .scheme.keyword
hilight .hilight.sql 1 "return"               .scheme.keyword
hilight .hilight.sql 1 "setof"               .scheme.keyword
hilight .hilight.sql 1 "elsif"               .scheme.keyword
hilight .hilight.sql 1 "raise"               .scheme.keyword
hilight .hilight.sql 1 "notice"               .scheme.keyword
hilight .hilight.sql 1 "loop"               .scheme.keyword
define-macro sql-copy-function
    set-alpha-mark "p"
    search-backward "^CREATE"
    beginning-of-line
    set-mark
    search-forward "^$$"
    exchange-point-and-mark
    copy-region
    goto-alpha-mark "p"
!emacro