unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Best practices for sql-list-(table|all)?
@ 2013-05-30  3:41 Trevor Murphy
  2013-05-30 13:35 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Trevor Murphy @ 2013-05-30  3:41 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

Hello, sql-mode-ers!

I'm revisiting SQL for work and I'd like to use Emacs as appropriate.
Unfortunately I don't have a local wizard to point me in the correct
direction when I'm confused by sql-mode and sql-interactive-mode
quirks.

For instance: I'm noticing that I must explicitly quit out of
view-mode after each invocation of sql-list-all / sql-list-table on a
particular table.  (I'm calling these commands frequently to look up
schema and table elements as I learn the database layout).  If instead
of quitting out of view-mode I just switch back to my sql-mode buffer,
the second call to the sql-list-foo command gives a "Buffer is
read-only" error.  Even after reading the source, I can't tell if this
is a bug or a pebkac.  If the former, I'm happy to dig in and try to
fix it.  If the latter, I'd love to know how the work flow goes for
familiar users.

Thanks for any insight, and please push me to another list if appropriate.

Trevor

[-- Attachment #2: Type: text/html, Size: 1037 bytes --]

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

* Re: Best practices for sql-list-(table|all)?
  2013-05-30  3:41 Best practices for sql-list-(table|all)? Trevor Murphy
@ 2013-05-30 13:35 ` Stefan Monnier
  2013-05-31  2:42   ` Trevor Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-05-30 13:35 UTC (permalink / raw)
  To: Trevor Murphy; +Cc: Michael Mauger, emacs-devel

> schema and table elements as I learn the database layout).  If instead
> of quitting out of view-mode I just switch back to my sql-mode buffer,
> the second call to the sql-list-foo command gives a "Buffer is
> read-only" error.

Sounds like a bug.  Either it shouldn't use view-mode, or (more likely)
it should let-bind inhibit-read-only around the code that (re)populates
the buffer.


        Stefan



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

* Re: Best practices for sql-list-(table|all)?
  2013-05-30 13:35 ` Stefan Monnier
@ 2013-05-31  2:42   ` Trevor Murphy
  2013-05-31  3:50     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Trevor Murphy @ 2013-05-31  2:42 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Michael Mauger, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

One would think!  I tracked the issue to the `sql-redirect-one'
function, which is responsible for re-populating the buffer.
Unfortunately I wasn't able to fix the problem for myself.

I tested including an (inhibit-read-only t) in the opening let form,
but still no joy.  Seems the call to
`comint-redirect-send-command-to-process' redirects output to the
target buffer then calls `process-send-string' (shocking, I know) and
that *latter* call gives the same error.

I don't know nearly enough about Emacs, but my current best guess is
that `process-send-string' just won't respect `inhibit-read-only'
because the former's a built-in C function.  Right now I'm trying to
figure out how best to manage the read-only status on the buffer (I'm
really new to the nuances of view-mode and toggling the read-only
flag).

Any pointers?  Right now I'm just jamming a (read-only-mode -1) and
(read-only-mode 1) at the top and bottom of `sql-redirect-one', but it
feels too gross to share.  I'd love to find out that I can get away
with a simple `inhibit-read-only' solution.



On Thu, May 30, 2013 at 9:35 AM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> > schema and table elements as I learn the database layout).  If instead
> > of quitting out of view-mode I just switch back to my sql-mode buffer,
> > the second call to the sql-list-foo command gives a "Buffer is
> > read-only" error.
>
> Sounds like a bug.  Either it shouldn't use view-mode, or (more likely)
> it should let-bind inhibit-read-only around the code that (re)populates
> the buffer.
>
>
>         Stefan
>

[-- Attachment #2: Type: text/html, Size: 2106 bytes --]

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

* Re: Best practices for sql-list-(table|all)?
  2013-05-31  2:42   ` Trevor Murphy
@ 2013-05-31  3:50     ` Stefan Monnier
  2013-07-03  3:34       ` Michael Mauger
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-05-31  3:50 UTC (permalink / raw)
  To: Trevor Murphy; +Cc: Michael Mauger, emacs-devel

> I don't know nearly enough about Emacs, but my current best guess is
> that `process-send-string' just won't respect `inhibit-read-only'
> because the former's a built-in C function.

No, but the process-send-string just returns right away, and the
response is inserted into the target buffer via the process-filter.

> Any pointers?  Right now I'm just jamming a (read-only-mode -1) and
> (read-only-mode 1) at the top and bottom of `sql-redirect-one', but it
> feels too gross to share.  I'd love to find out that I can get away
> with a simple `inhibit-read-only' solution.

I don't know why turning the mode off and then back on would work while
let-binding inhibit-read-only wouldn't.  Maybe Michael can think of
some reason?


        Stefan



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

* Re: Best practices for sql-list-(table|all)?
  2013-05-31  3:50     ` Stefan Monnier
@ 2013-07-03  3:34       ` Michael Mauger
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Mauger @ 2013-07-03  3:34 UTC (permalink / raw)
  To: Trevor Murphy; +Cc: Stefan Monnier, emacs-devel@gnu.org

> From: Stefan Monnier <monnier@iro.umontreal.ca>

>To: Trevor Murphy <trevor.m.murphy@gmail.com> 
>Sent: Thursday, May 30, 2013 11:50 PM
>
>> I don't know nearly enough about Emacs, but my current best guess is
>> that `process-send-string' just won't respect `inhibit-read-only'
>> because the former's a built-in C function.
>
>No, but the process-send-string just returns right away, and the
>response is inserted into the target buffer via the process-filter.
>
>> Any pointers?  Right now I'm just jamming a (read-only-mode -1) and
>> (read-only-mode 1) at the top and bottom of `sql-redirect-one', but it
>> feels too gross to share.  I'd love to find out that I can get away
>> with a simple `inhibit-read-only' solution.
>
>I don't know why turning the mode off and then back on would work while
>let-binding inhibit-read-only wouldn't.  Maybe Michael can think of
>some reason?
>

I apologize for the delay in my response.  


I had encountered the same issue and thought the fix had already been 

moved to trunk.  Digging in tonite, it doesn't appear it made it; so I'll get 

it installed this week.  I had a similar problem with using inhibit-read-only, 

but found that controlling buffer-read-only was actually a more accurate 

way of managing the buffer's read-only state and the buffer's contents.

Thanks for the bug report and sorry for my delay


-- Michael



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

end of thread, other threads:[~2013-07-03  3:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-30  3:41 Best practices for sql-list-(table|all)? Trevor Murphy
2013-05-30 13:35 ` Stefan Monnier
2013-05-31  2:42   ` Trevor Murphy
2013-05-31  3:50     ` Stefan Monnier
2013-07-03  3:34       ` Michael Mauger

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).