Trevoke / sqlup-mode.el

An emacs minor mode to upcase SQL keyword and functions
GNU General Public License v3.0
86 stars 15 forks source link

[org] How to use sqlup in org sql code block #71

Closed braoult closed 4 years ago

braoult commented 4 years ago

I use sqlup in my "sql-mode" buffers, it is perfect, thanks for this mode.

However, I am starting to use org-mode for my developments and have SQL code blocks, such as:

#+NAME:foo
#+BEGIN_SRC sql  :noweb no-export :tangle
SELECT 1 as res;
#+END_SRC

sqlindent works well in these blocks, but I don't know how I could also get sqlup to up-case SQL keywords.

For example, in source above, I when I type "as" followed by a <space>, absolutely nothing happened. Is there a way to do it ?

Trevoke commented 4 years ago

Hi Bruno,

Org-mode allows one to edit code blocks in a sub-buffer with the correct major mode, the usual shortcut to toggle it is C-c '. That is the simplest way I've found to use packages like sqlup-mode while doing things like literate programming (or blog entries).

I hope this helps - let me know (or close the issue if this is enough for you).

On Mon, Aug 31, 2020 at 5:20 AM Bruno Raoult notifications@github.com wrote:

I use sqlup in my "sql-mode" buffers, it is perfect, thanks for this mode.

However, I am starting to use org-mode for my developments and have SQL code blocks, such as:

+NAME:foo

+BEGIN_SRC sql :noweb no-export :tangle

SELECT 1 as res;

+END_SRC

sqlindent works well in these blocks, but I don't know how I could also get sqlup to up-case SQL keywords.

For example, in source above, I when I types "as" followed by a , absolutely nothing happened. Is there a way to do it ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Trevoke/sqlup-mode.el/issues/71, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQSSOMBFUWT6QAUYKYVQTSDNTPJANCNFSM4QQJTOQQ .

braoult commented 4 years ago

Hi Trevoke,

It will be a workaround, but I don't understand how it is "sql-mode" and "sqlindent-mode" are handled inside the code block, without having to use another specific buffer (I mean without using C-c ')... But I am new to code-blocks, maybe there are some tricks I miss somewhere.

Note, strangely, trying sqlup-capitalize-keywords-in-region in such a code block gives the error "Not enabling jit-lock: it does not work in indirect buffer", and the whole org buffer (not only the SQL code block) loses highlighting. However, the SQL keywords are correctly capitalized.

Could there be a link with #63, as message was the same, and there was also a syntax highlighting problem?

Trevoke commented 4 years ago

I honestly don't know how org-mode does this and that means I don't know if there's a way to hook into org-mode to ask it to enable sqlup-mode selectively when the code block is a sql code block.

I think technically using C-c ' isn't a workaround, it's the way you're supposed to interact with the code blocks.

All this being said, it's a cool idea, but I don't know how to solve it. I can redirect you to reddit's orgmode subreddit ( /r/orgmode ) maybe, or the org-mode mailing lists, to ask how to connect sqlup-mode to the inline editing of a src code block. If anyone knows, it'll likely be someone on the mailing list, but the subreddit has pleasantly surprised me before :)

braoult commented 4 years ago

In fact, I did discuss on (freenode) #org-mode yesterday, with no success... Maybe #emacs would be a better channel, I will ask there too.

For me, using C-c ' is really a workaround: it is very different from inline editing (same in web-mode with embedded php, for instance: I don't use another buffer to edit and have indent/syntax highlighting working for PHP).

I will try to find another workaround, or have a look at sqlup code, to see what is different with sqlind minor mode (both make change to text), having one allowing inline editing (sqlind), and the other not (sqlup).

Closing for now, I will let you know if I find something more usable than C-c '

Thanks again for this mode !

Trevoke commented 4 years ago

It's my pleasure and I hope you find what you're looking for!

Two things worth noting:

  1. web-mode does some magic to allow multiple major modes (HTML and whatever other language), I don't know the details
  2. syntax highlighting and indentation are features built-in to emacs (unless this sqlind thing you mention is an external package?), so there may be some specific rules at play

This being said, I hope you're wrong, and I hope you can teach me something really cool! I would go and learn this myself, but ... I have failed to learn this a few times, so maybe I'm not thinking about it well enough.

On Wed, Sep 2, 2020 at 1:31 PM Bruno Raoult notifications@github.com wrote:

In fact, I did discuss on (freenode) #org-mode yesterday, with no success... Maybe #emacs would be a better channel, I will ask there too.

For me, using C-c ' is really a workaround: it is very different from inline editing (same in web-mode with embedded php, for instance: I don't use another buffer to edit and have indent/syntax highlighting working for PHP).

I will try to find another workaround, or have a look at sqlup code, to see what is different with sqlind minor mode (both make change to text), having one allowing inline editing (sqlind), and the other not (sqlup).

Closing for now, I will let you know if I find something more usable than C-c '

Thanks again for this mode !

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Trevoke/sqlup-mode.el/issues/71#issuecomment-685887521, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQSSJZIUJ56DZTWRIYW73SDZ6PDANCNFSM4QQJTOQQ .