all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using backward-char non-interactively
@ 2013-12-31 13:58 Marcin Borkowski
  2013-12-31 18:10 ` Andreas Röhler
  0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2013-12-31 13:58 UTC (permalink / raw)
  To: GNU Emacs users list

Hi,

is it ok to use backward-char in elisp programs assuming that I did
check that I'm not at beginning of buffer?  Or is it better to use
(goto-char (1- point)) or something like that?  Or maybe it doesn't
matter?  ("Better" may be in terms of style, speed, or side effects,
like cluttering the *Messages* buffer.)

TIA,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



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

* Re: Using backward-char non-interactively
       [not found] <mailman.10751.1388498331.10748.help-gnu-emacs@gnu.org>
@ 2013-12-31 14:56 ` Barry Margolin
  2013-12-31 17:55   ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Barry Margolin @ 2013-12-31 14:56 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.10751.1388498331.10748.help-gnu-emacs@gnu.org>,
 Marcin Borkowski <mbork@wmi.amu.edu.pl> wrote:

> Hi,
> 
> is it ok to use backward-char in elisp programs assuming that I did
> check that I'm not at beginning of buffer?  Or is it better to use
> (goto-char (1- point)) or something like that?  Or maybe it doesn't
> matter?  ("Better" may be in terms of style, speed, or side effects,
> like cluttering the *Messages* buffer.)

Most command functions are OK to use in programs. The handful that 
shouldn't say something in their documentation string, usually with a 
pointer to an alternative function that's better.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: Using backward-char non-interactively
  2013-12-31 14:56 ` Using backward-char non-interactively Barry Margolin
@ 2013-12-31 17:55   ` Emanuel Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2013-12-31 17:55 UTC (permalink / raw)
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:

> Most command functions are OK to use in programs. The
> handful that shouldn't say something in their
> documentation string, usually with a pointer to an
> alternative function that's better.

Example, `beginning-of-buffer':

> Don't use this command in Lisp programs!
> (goto-char (point-min)) is faster.

-- 
underground experts united:
http://user.it.uu.se/~embe8573


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

* Re: Using backward-char non-interactively
  2013-12-31 13:58 Marcin Borkowski
@ 2013-12-31 18:10 ` Andreas Röhler
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2013-12-31 18:10 UTC (permalink / raw)
  To: help-gnu-emacs

Am 31.12.2013 14:58, schrieb Marcin Borkowski:
> Hi,
>
> is it ok to use backward-char in elisp programs assuming that I did
> check that I'm not at beginning of buffer?  Or is it better to use
> (goto-char (1- point)) or something like that?  Or maybe it doesn't
> matter?  ("Better" may be in terms of style, speed, or side effects,
> like cluttering the *Messages* buffer.)
>
> TIA,
>

Hi,

answer depends from the case.

In general it's okay.
If you must avoid any messages, would use (unless (bobp)

Here a from to try it:

(funcall (lambda ()(goto-char 1)(unless (bobp)(backward-char))))




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

end of thread, other threads:[~2013-12-31 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.10751.1388498331.10748.help-gnu-emacs@gnu.org>
2013-12-31 14:56 ` Using backward-char non-interactively Barry Margolin
2013-12-31 17:55   ` Emanuel Berg
2013-12-31 13:58 Marcin Borkowski
2013-12-31 18:10 ` Andreas Röhler

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.