Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An emacs minor mode to upcase SQL keyword and functions

License

NotificationsYou must be signed in to change notification settings

Trevoke/sqlup-mode.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

sqlup-mode

sqlup-mode is a minor mode for emacs. Its sole purpose is to makeyour life easier when writing SQL.

Purpose

SQL, by convention, uses upper-case keywords, although lower-caseworks just as well. As humans, the separation between upper-case andlower-case helps scan and parse the code much more quickly.

This mode has been extended to upcase keywords when usingredis-modeas well.

Pronunciation

I gave a talk(slides) at theemacs NYC meetup, and it was decided thatsqlup is pronouncedskloop.

Installation

Manually

Content TK. Pull request welcome. Same as all other emacs packages,really.

MELPA

MELPAMELPA Stable

Marmalade

sqlup-mode is NOT YET on Marmalade.

Usage

Basic setup

Here follows an example setup to activatesqlup-mode automatically when entering sql-mode or sql-interactive-mode:

;; Capitalize keywords in SQL mode(add-hook'sql-mode-hook'sqlup-mode);; Capitalize keywords in an interactive session (e.g. psql)(add-hook'sql-interactive-mode-hook'sqlup-mode);; Set a global keyword to use sqlup on a region(global-set-key (kbd"C-c u")'sqlup-capitalize-keywords-in-region)

Blacklisting words

Sqlup can be configured to ignore certain keywords by adding them to the listsqlup-blacklist. For example if you usename as a column name it would beannoying to have it upcased so you can prevent this by adding

(add-to-list'sqlup-blacklist"name")

to your config (or do the equivalent through theM-x customize interface).

Normal typing (e.g. SQL REPL)

Activate the minor mode withM-x sqlup-mode and you can just starttyping. The minor mode will be triggered by the following keys:

  • SPC
  • (
  • ,
  • ;
  • RET
  • '

Work with a region

Select a region and just callM-x sqlup-capitalize-keywords-in-region.Magic.

Work with a whole buffer

Just callM-x sqlup-capitalize-keywords-in-buffer.

Implementation choices

I made the choice of only triggering the word-scanning when a particular keypress happens specifically because I don't want to see the word "ORde" typed when I'm typing "ORDER", and I didn't know asimple way to do it. I believe that in practice, this is good enough.


[8]ページ先頭

©2009-2025 Movatter.jp