all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Problem understanding set-register syntax
@ 2010-12-05  9:51 Aurélien Bottazzini
  2010-12-06 22:23 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Aurélien Bottazzini @ 2010-12-05  9:51 UTC (permalink / raw
  To: help-gnu-emacs

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

Hello everyone,

in my init.el I have

(set-register ?i '(file . "~/.emacs.d/init.el"))

which allows me to quickly jump to my init file using C-x r j i
But I don't really understand the syntax.
Why do I have to use the exclamation mark when I set the register?

Why can't I just use:

(set-register i '(file . "~/.emacs.d/init.el")) ; will say Symbol's value as
variable is void:i

I tried to search in the documentation for set-register and variable
definition but I did not find
anything to really explain it.

Thanks for any help.

Aurélien

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

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

* Problem understanding set-register syntax
@ 2010-12-06 13:47 Aurélien Bottazzini
  2010-12-06 22:46 ` PJ Weisberg
  0 siblings, 1 reply; 5+ messages in thread
From: Aurélien Bottazzini @ 2010-12-06 13:47 UTC (permalink / raw
  To: help-gnu-emacs

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

(sorry if this email is a duplicate, but the first one was lost apparently)

Hello everyone,

in my init.el I have

(set-register ?i '(file . "~/.emacs.d/init.el"))

which allows me to quickly jump to my init file using C-x r j i
But I don't really understand the syntax.
Why do I have to use the exclamation mark when I set the register?

Why can't I just use:

(set-register i '(file . "~/.emacs.d/init.el")) ; will say Symbol's value as
variable is void:i

I tried to search in the documentation for set-register and variable
definition but I did not find
anything to really explain it.

Thanks for any help.

Aurélien

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

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

* RE: Problem understanding set-register syntax
  2010-12-05  9:51 Problem understanding set-register syntax Aurélien Bottazzini
@ 2010-12-06 22:23 ` Drew Adams
  2010-12-06 22:54   ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2010-12-06 22:23 UTC (permalink / raw
  To: 'Aurélien Bottazzini', help-gnu-emacs

> in my init.el I have
> (set-register ?i '(file . "~/.emacs.d/init.el"))
> which allows me to quickly jump to my init file using C-x r j i
> But I don't really understand the syntax.
> Why do I have to use the exclamation mark when I set the register?

You mean question mark, I think.
	
> Why can't I just use:
> (set-register i '(file . "~/.emacs.d/init.el"))
> ; will say Symbol's value as variable is void:i

Because the first argument to `set-register' is a register name, which is a
character, and `?i' is the Lisp syntax for the character `i'.
	
> I tried to search in the documentation for set-register and
> variable definition but I did not find anything to really explain it.

Please file a doc bug for `C-h f set-register'.  The doc should say clearly what
each parameter is.  In this case it says nothing about the first parameter
except that it is a register.  It expects readers to somehow know that a
register (its name, that is) is of type character.

Relevant doc that will help you:

1. Elisp manual, node `Registers':

 "A register is a sort of variable used in Emacs editing that
  can hold a variety of different kinds of values.  Each
  register is named by a single character."

IOW, a register is like a variable in that it has a name and a value.  The name
is a character, however, not a symbol.

2. Emacs manual, node `Registers':

 "Emacs "registers" are compartments where you can save text, rectangles,
  positions, and other things for later use....
  Each register has a name that consists of a single character, which
  we will denote by R; R can be a letter (such as `a') or a number (such
  as `1'); case matters, so register `a' is not the same as register `A'."




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

* Re: Problem understanding set-register syntax
  2010-12-06 13:47 Aurélien Bottazzini
@ 2010-12-06 22:46 ` PJ Weisberg
  0 siblings, 0 replies; 5+ messages in thread
From: PJ Weisberg @ 2010-12-06 22:46 UTC (permalink / raw
  To: help-gnu-emacs

On Mon, Dec 6, 2010 at 5:47 AM, Aurélien Bottazzini
<aurelien.bottazzini@gmail.com> wrote:
> (sorry if this email is a duplicate, but the first one was lost apparently)
> Hello everyone,
> in my init.el I have
> (set-register ?i '(file . "~/.emacs.d/init.el"))
> which allows me to quickly jump to my init file using C-x r j i
> But I don't really understand the syntax.
> Why do I have to use the exclamation mark when I set the register?
> Why can't I just use:
> (set-register i '(file . "~/.emacs.d/init.el")) ; will say Symbol's value as
> variable is void:i
> I tried to search in the documentation for set-register and variable
> definition but I did not find
> anything to really explain it.
> Thanks for any help.
> Aurélien

English:
    !: exclamation mark (more commonly "exclamation point")
    ?: question mark

Emacs:
    ?i:  The character 'i' (which, technically, is equal to the number 105).
    i:  A variable represented by the symbol i.

Consider the difference between:

int i = 0;

and

int 'i' = 0;

-PJ



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

* RE: Problem understanding set-register syntax
  2010-12-06 22:23 ` Drew Adams
@ 2010-12-06 22:54   ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2010-12-06 22:54 UTC (permalink / raw
  To: 'Aurélien Bottazzini', help-gnu-emacs

> > Why can't I just use:
> > (set-register i '(file . "~/.emacs.d/init.el"))
> > ; will say Symbol's value as variable is void:i
> 
> Because the first argument to `set-register' is a register 
> name, which is a character, and `?i' is the Lisp syntax for
> the character `i'.

I should also have mentioned that using just i, without quoting it (i.e., 'i)
causes the symbol i to be evaluated.  And since the symbol i has no value here
(no global value) you get the error message saying that its value is void.

Some symbols, such as t and nil (and all keywords, such as :foobar) are
self-evaluating, meaning that they act just like variables whose values are the
symbols themselves.  You do not need to quote self-evaluating symbols in an
evaluation context.  Other symbols (e.g. i, foobar) you do need to quote, if you
want not the value of the symbol (e.g. it might not have a value) but the symbol
itself.

But all characters are self-evaluating, so ?i evaluates to ?i.

See the Emacs manual, node `Init Syntax'.
See the Elisp manual, node `Basic Char Syntax'.
(Use `g' in Info to go to a particular node.)




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

end of thread, other threads:[~2010-12-06 22:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05  9:51 Problem understanding set-register syntax Aurélien Bottazzini
2010-12-06 22:23 ` Drew Adams
2010-12-06 22:54   ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2010-12-06 13:47 Aurélien Bottazzini
2010-12-06 22:46 ` PJ Weisberg

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.