all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Signaling text-read-only
@ 2011-02-15  3:35 Deniz Dogan
  2011-02-15  4:52 ` Leo
  0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2011-02-15  3:35 UTC (permalink / raw)
  To: Emacs-Devel devel

I have a situation here where I need to tell the user that the part of
the buffer where point is located is read-only. This is what I am
thinking right now:

(unless (rcirc-looking-at-input)
  (error (error-message-string (list 'text-read-only)))

or:

(unless (rcirc-looking-at-input)
  (signal 'text-read-only nil)))

I haven't found any examples of this explicit sort of signaling in the
other Lisp files in Emacs, but I might have missed something.

The reason why I need this is that `rcirc-complete' shouldn't be
called in read-only areas of the buffer.

What is the right way to do this?

-- 
Deniz Dogan



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

* Re: Signaling text-read-only
  2011-02-15  3:35 Signaling text-read-only Deniz Dogan
@ 2011-02-15  4:52 ` Leo
  2011-02-15 10:38   ` Deniz Dogan
  0 siblings, 1 reply; 4+ messages in thread
From: Leo @ 2011-02-15  4:52 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On 2011-02-15 11:35 +0800, Deniz Dogan wrote:
> I have a situation here where I need to tell the user that the part of
> the buffer where point is located is read-only. This is what I am
> thinking right now:
>
> (unless (rcirc-looking-at-input)
>   (error (error-message-string (list 'text-read-only)))
>
> or:
>
> (unless (rcirc-looking-at-input)
>   (signal 'text-read-only nil)))
>
> I haven't found any examples of this explicit sort of signaling in the
> other Lisp files in Emacs, but I might have missed something.
>
> The reason why I need this is that `rcirc-complete' shouldn't be
> called in read-only areas of the buffer.
>
> What is the right way to do this?

The question arose when Deniz and I discussed the patch here:
http://paste.pocoo.org/raw/gUNWgGTy4zMSI0ApR3vZ/ in #emacs.

As required by completion-at-point-functions, it makes sense for
rcirc-completion-at-point to return nil when re-search-backward errs and
therefore for rcirc-complete to handle the case when completion table is
nil so I think the patch is applicable regardless of whether or not to
signal an error.

I think it is good idea to give some feedback to user but I think
text-read-only is not the right one (the error is not caused by
text-read-only). It should probably be something like:

(unless (rcirc-looking-at-input)
  (error "Point not located after rcirc prompt"))

to be added at the very beginning of rcirc-complete function body.

What do you think?

Leo



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

* Re: Signaling text-read-only
  2011-02-15  4:52 ` Leo
@ 2011-02-15 10:38   ` Deniz Dogan
  2011-03-22 11:56     ` Leo
  0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2011-02-15 10:38 UTC (permalink / raw)
  To: Leo; +Cc: Emacs-Devel devel

2011/2/15 Leo <sdl.web@gmail.com>:
> On 2011-02-15 11:35 +0800, Deniz Dogan wrote:
>> I have a situation here where I need to tell the user that the part of
>> the buffer where point is located is read-only. This is what I am
>> thinking right now:
>>
>> (unless (rcirc-looking-at-input)
>>   (error (error-message-string (list 'text-read-only)))
>>
>> or:
>>
>> (unless (rcirc-looking-at-input)
>>   (signal 'text-read-only nil)))
>>
>> I haven't found any examples of this explicit sort of signaling in the
>> other Lisp files in Emacs, but I might have missed something.
>>
>> The reason why I need this is that `rcirc-complete' shouldn't be
>> called in read-only areas of the buffer.
>>
>> What is the right way to do this?
>
> The question arose when Deniz and I discussed the patch here:
> http://paste.pocoo.org/raw/gUNWgGTy4zMSI0ApR3vZ/ in #emacs.
>
> As required by completion-at-point-functions, it makes sense for
> rcirc-completion-at-point to return nil when re-search-backward errs and
> therefore for rcirc-complete to handle the case when completion table is
> nil so I think the patch is applicable regardless of whether or not to
> signal an error.
>
> I think it is good idea to give some feedback to user but I think
> text-read-only is not the right one (the error is not caused by
> text-read-only). It should probably be something like:
>
> (unless (rcirc-looking-at-input)
>  (error "Point not located after rcirc prompt"))
>
> to be added at the very beginning of rcirc-complete function body.
>
> What do you think?
>

I'm fine with your error suggestion as well. I just figured it would
make sense to signal text-read-only, since whatever the command
completed to wouldn't be inserted at point, as that part of the buffer
is read-only.

-- 
Deniz Dogan



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

* Re: Signaling text-read-only
  2011-02-15 10:38   ` Deniz Dogan
@ 2011-03-22 11:56     ` Leo
  0 siblings, 0 replies; 4+ messages in thread
From: Leo @ 2011-03-22 11:56 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On 2011-02-15 18:38 +0800, Deniz Dogan wrote:
> I'm fine with your error suggestion as well. I just figured it would
> make sense to signal text-read-only, since whatever the command
> completed to wouldn't be inserted at point, as that part of the buffer
> is read-only.

I installed something as discussed. Feel free to tweak the error message
if you think 'text-read-only is better.

Cheers,
Leo



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

end of thread, other threads:[~2011-03-22 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-15  3:35 Signaling text-read-only Deniz Dogan
2011-02-15  4:52 ` Leo
2011-02-15 10:38   ` Deniz Dogan
2011-03-22 11:56     ` Leo

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.