all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indenting SQL in php_mode
@ 2008-12-07 19:45 Frank Thieme
  2008-12-08  5:57 ` Ian Eure
       [not found] ` <mailman.2196.1228715850.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Frank Thieme @ 2008-12-07 19:45 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

After years I'm back on Emacs. At the moment I'm writing a PHP/Mysql
project and wonder how I can get some indentation on the SQL statements
within PHP code.

When I write function calls like

foo($bar,
    $foobar);

I can indent pressing <Tab> key. But when I do same for SQL just nothing
happens:

$query = "SELECT foo
FROM bar
WHERE foobar"

I have to manually indent...

any hints?

Bye...Frank



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
  2008-12-07 19:45 indenting SQL in php_mode Frank Thieme
@ 2008-12-08  5:57 ` Ian Eure
       [not found] ` <mailman.2196.1228715850.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Ian Eure @ 2008-12-08  5:57 UTC (permalink / raw)
  To: Frank Thieme; +Cc: help-gnu-emacs

On Dec 7, 2008, at 11:45 AM, Frank Thieme wrote:

> Hi!
>
> After years I'm back on Emacs. At the moment I'm writing a PHP/Mysql
> project and wonder how I can get some indentation on the SQL  
> statements
> within PHP code.
>
> When I write function calls like
>
> foo($bar,
>    $foobar);
>
> I can indent pressing <Tab> key. But when I do same for SQL just  
> nothing
> happens:
>
> $query = "SELECT foo
> FROM bar
> WHERE foobar"
>
> I have to manually indent...
>
> any hints?
>
There's no easy solution, unfortunately. I think the only thing you  
can do is et up MMM or MuMaMo so those regions are sql-mode instead of  
php-mode, and use sql-indent.el.

I've never had the patience to get either of those working, so I just  
align it by hand in the source, or edit the query in a *SQL* buffer,  
then dump it into the source in a here document.

  - Ian




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
       [not found] ` <mailman.2196.1228715850.26697.help-gnu-emacs@gnu.org>
@ 2008-12-08 11:08   ` Frank Thieme
  2008-12-08 13:32     ` Lennart Borgman
       [not found]     ` <mailman.2226.1228743177.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Frank Thieme @ 2008-12-08 11:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Mo 08 Dez 2008 06:57, Ian Eure <ian@digg.com> writes:

> There's no easy solution, unfortunately. I think the only thing you
> can do is et up MMM or MuMaMo so those regions are sql-mode instead of
> php-mode, and use sql-indent.el.
>
> I've never had the patience to get either of those working, so I just
> align it by hand in the source, or edit the query in a *SQL* buffer,
> then dump it into the source in a here document.

Mmh, I know what you mean. I think it would be sufficient if indentation
is like in text-mode, but somehow this seems to be disabled.

Bye...Frank


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
  2008-12-08 11:08   ` Frank Thieme
@ 2008-12-08 13:32     ` Lennart Borgman
       [not found]     ` <mailman.2226.1228743177.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Lennart Borgman @ 2008-12-08 13:32 UTC (permalink / raw)
  To: Frank Thieme; +Cc: help-gnu-emacs

On Mon, Dec 8, 2008 at 12:08 PM, Frank Thieme <fthieme@gmx.net> wrote:
> On Mo 08 Dez 2008 06:57, Ian Eure <ian@digg.com> writes:
>
>> There's no easy solution, unfortunately. I think the only thing you
>> can do is et up MMM or MuMaMo so those regions are sql-mode instead of
>> php-mode, and use sql-indent.el.
>>
>> I've never had the patience to get either of those working, so I just
>> align it by hand in the source, or edit the query in a *SQL* buffer,
>> then dump it into the source in a here document.

Could you please show me some examples of how sql in php look? (Delimiters etc.)




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
       [not found]     ` <mailman.2226.1228743177.26697.help-gnu-emacs@gnu.org>
@ 2008-12-08 14:01       ` Frank Thieme
  2008-12-08 16:27         ` Lennart Borgman
       [not found]         ` <mailman.2236.1228753665.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Frank Thieme @ 2008-12-08 14:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Mo 08 Dez 2008 14:32, "Lennart Borgman" <lennart.borgman@gmail.com> writes:

> Could you please show me some examples of how sql in php look? (Delimiters etc.)

I don't know whether there is a standard, but I do it like this:

$query = "SELECT field1,
                 field2,
                 field3
          FROM table1 t1,
               table2 t2
          WHERE t1.foo = t2.bar
            AND field1 = 'foobar'";

Bye...Frank


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
  2008-12-08 14:01       ` Frank Thieme
@ 2008-12-08 16:27         ` Lennart Borgman
  2008-12-08 17:38           ` Ian Eure
       [not found]         ` <mailman.2236.1228753665.26697.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Lennart Borgman @ 2008-12-08 16:27 UTC (permalink / raw)
  To: Frank Thieme; +Cc: help-gnu-emacs

On Mon, Dec 8, 2008 at 3:01 PM, Frank Thieme <fthieme@gmx.net> wrote:
> On Mo 08 Dez 2008 14:32, "Lennart Borgman" <lennart.borgman@gmail.com> writes:
>
>> Could you please show me some examples of how sql in php look? (Delimiters etc.)
>
> I don't know whether there is a standard, but I do it like this:
>
> $query = "SELECT field1,
>                 field2,
>                 field3
>          FROM table1 t1,
>               table2 t2
>          WHERE t1.foo = t2.bar
>            AND field1 = 'foobar'";

Thanks, Frank, but I thoiught you meant a file with mixed php and sql
code, or? How does the delimiters from the php code look?




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
       [not found]         ` <mailman.2236.1228753665.26697.help-gnu-emacs@gnu.org>
@ 2008-12-08 17:38           ` Frank Thieme
  0 siblings, 0 replies; 9+ messages in thread
From: Frank Thieme @ 2008-12-08 17:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Mo 08 Dez 2008 17:27, "Lennart Borgman" <lennart.borgman@gmail.com> writes:

> Thanks, Frank, but I thoiught you meant a file with mixed php and sql
> code, or? How does the delimiters from the php code look?

This is mixed code - it is a PHP string containing a SQL query. I'm
sorry, I don't really know what information do you need...

For more examples you could look at the PHP manual of the Mysql
interface:

e.g.: http://de.php.net/manual/en/function.mysql-query.php

Bye...Frank




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
  2008-12-08 16:27         ` Lennart Borgman
@ 2008-12-08 17:38           ` Ian Eure
  2008-12-09  0:10             ` Lennart Borgman
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Eure @ 2008-12-08 17:38 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Frank Thieme, help-gnu-emacs

On Dec 8, 2008, at 8:27 AM, Lennart Borgman wrote:

> On Mon, Dec 8, 2008 at 3:01 PM, Frank Thieme <fthieme@gmx.net> wrote:
>> On Mo 08 Dez 2008 14:32, "Lennart Borgman"  
>> <lennart.borgman@gmail.com> writes:
>>
>>> Could you please show me some examples of how sql in php look?  
>>> (Delimiters etc.)
>>
>> I don't know whether there is a standard, but I do it like this:
>>
>> $query = "SELECT field1,
>>                field2,
>>                field3
>>         FROM table1 t1,
>>              table2 t2
>>         WHERE t1.foo = t2.bar
>>           AND field1 = 'foobar'";
>
> Thanks, Frank, but I thoiught you meant a file with mixed php and sql
> code, or? How does the delimiters from the php code look?
>
It's not like PHP-in-HTML, where there are explicit delimiters. It's  
just stored in a variable as a long string.

You'd have to use the variable declaration as the delimiter and force  
people to use $sql (or whatever).

  - Ian




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: indenting SQL in php_mode
  2008-12-08 17:38           ` Ian Eure
@ 2008-12-09  0:10             ` Lennart Borgman
  0 siblings, 0 replies; 9+ messages in thread
From: Lennart Borgman @ 2008-12-09  0:10 UTC (permalink / raw)
  To: Ian Eure; +Cc: Frank Thieme, help-gnu-emacs

On Mon, Dec 8, 2008 at 6:38 PM, Ian Eure <ian@digg.com> wrote:
> On Dec 8, 2008, at 8:27 AM, Lennart Borgman wrote:
>
>> On Mon, Dec 8, 2008 at 3:01 PM, Frank Thieme <fthieme@gmx.net> wrote:
>>>
>>> On Mo 08 Dez 2008 14:32, "Lennart Borgman" <lennart.borgman@gmail.com>
>>> writes:
>>>
>>>> Could you please show me some examples of how sql in php look?
>>>> (Delimiters etc.)
>>>
>>> I don't know whether there is a standard, but I do it like this:
>>>
>>> $query = "SELECT field1,
>>>               field2,
>>>               field3
>>>        FROM table1 t1,
>>>             table2 t2
>>>        WHERE t1.foo = t2.bar
>>>          AND field1 = 'foobar'";
>>
>> Thanks, Frank, but I thoiught you meant a file with mixed php and sql
>> code, or? How does the delimiters from the php code look?
>>
> It's not like PHP-in-HTML, where there are explicit delimiters. It's just
> stored in a variable as a long string.
>
> You'd have to use the variable declaration as the delimiter and force people
> to use $sql (or whatever).

Ah, thanks, I see. This is of course possible to do, something similar
is done for style="..." in for example nxhtml-mumamo-mode. However
here it looks like something more flexible would be good. I will put
it on my todo-list.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-12-09  0:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-07 19:45 indenting SQL in php_mode Frank Thieme
2008-12-08  5:57 ` Ian Eure
     [not found] ` <mailman.2196.1228715850.26697.help-gnu-emacs@gnu.org>
2008-12-08 11:08   ` Frank Thieme
2008-12-08 13:32     ` Lennart Borgman
     [not found]     ` <mailman.2226.1228743177.26697.help-gnu-emacs@gnu.org>
2008-12-08 14:01       ` Frank Thieme
2008-12-08 16:27         ` Lennart Borgman
2008-12-08 17:38           ` Ian Eure
2008-12-09  0:10             ` Lennart Borgman
     [not found]         ` <mailman.2236.1228753665.26697.help-gnu-emacs@gnu.org>
2008-12-08 17:38           ` Frank Thieme

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.