* Emacs lisp programming help
@ 2006-03-16 7:15 yeogirl
2006-03-16 7:47 ` Pascal Bourguignon
0 siblings, 1 reply; 5+ messages in thread
From: yeogirl @ 2006-03-16 7:15 UTC (permalink / raw)
Can anyone write me a short emacs list programming which changes its
buffer to corresponding .h or .cc files?
For example, if I work on a buffer, foo.cc and I want to switch to
buffer foo.h, I like to use a hot key such as meta-h to change to
foo.h. I can also do the same hot key change back to foo.cc. I used to
have the feature in my old machine...but I misplaced the code!
Anyhelp would be greatly appreciated!! Thank you!!
Yeogirl.
PS. PLEASE email me your message when you post a reply!! THANKS!!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Emacs lisp programming help
2006-03-16 7:15 Emacs " yeogirl
@ 2006-03-16 7:47 ` Pascal Bourguignon
0 siblings, 0 replies; 5+ messages in thread
From: Pascal Bourguignon @ 2006-03-16 7:47 UTC (permalink / raw)
yeogirl@gmail.com writes:
> Can anyone write me a short emacs list programming which changes its
> buffer to corresponding .h or .cc files?
>
> For example, if I work on a buffer, foo.cc and I want to switch to
> buffer foo.h, I like to use a hot key such as meta-h to change to
> foo.h. I can also do the same hot key change back to foo.cc. I used to
> have the feature in my old machine...but I misplaced the code!
>
> Anyhelp would be greatly appreciated!! Thank you!!
(require 'cl)
(defvar *c-sources-extensions* '("cc" "c" "m" "c++" "C"))
(defun* swap-h-c ()
(interactive)
(let* ((name (buffer-file-name))
(exte (file-name-extension name)))
(cond ((string= "h" exte)
(dolist (ext *c-sources-extensions*)
(let ((other (format "%s.%s"
(file-name-sans-extension name) ext)))
(when (file-exists-p other)
(find-file other)
(return-from swap-h-c))))
(find-file (format "%s.%s"
(file-name-sans-extension name)
(first *c-sources-extensions*))))
((member* exte *c-sources-extensions* :test (function string=))
(find-file (format "%s.%s"
(file-name-sans-extension name) "h")))
(t (beep)))))
--
__Pascal Bourguignon__ http://www.informatimago.com/
This is a signature virus. Add me to your signature and help me to live.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: emacs lisp programming help
[not found] <2c75e627-536b-47b7-8569-20781b041336@v39g2000pro.googlegroups.com>
@ 2009-01-29 18:13 ` Pascal J. Bourguignon
2009-01-29 18:49 ` ramestica
0 siblings, 1 reply; 5+ messages in thread
From: Pascal J. Bourguignon @ 2009-01-29 18:13 UTC (permalink / raw)
To: help-gnu-emacs
ramestica@gmail.com writes:
> in my .emacs. file I have some logic for setting my prefer font. I
In general, emacs questions (even emacs lisp) would be better answered
in one of the emacs newsgroups, such as news:gnu.emacs.help. However,
this one is not specific to emacs, so we'll answer here:
> tried something like this:
>
> ;; f-name and f-size-default are strings set to something
> ;; reasonable
> (setq my-default-font (concat f-name f-size-default))
> (add-to-list 'default-frame-alist '(font . my-default-font))
>
> then when I start emacs I get logs like this
>
> frame-notice-user-settings: Invalid font: my-default-font
>
> It seems to be a lisp thing that I cannot grasp. Why is that the value
> of my-default-font is not replaced in the last expression?
What does the quote do? What does 'x evaluate to?
And what does '(a b c) evaluate to?
And what does '(a . b) evaluate to?
So what does '(font . my-default-font) evaluate to?
What other mean to create a cons cell do you know?
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: emacs lisp programming help
2009-01-29 18:13 ` emacs lisp programming help Pascal J. Bourguignon
@ 2009-01-29 18:49 ` ramestica
2009-01-29 19:37 ` Pascal J. Bourguignon
0 siblings, 1 reply; 5+ messages in thread
From: ramestica @ 2009-01-29 18:49 UTC (permalink / raw)
To: help-gnu-emacs
On Jan 29, 1:13 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> In general, emacs questions (even emacs lisp) would be
I was about to do that but then I hesitated and look for a forum with
the word 'lisp' on it.
> What does the quote do? What does 'x evaluate to?
> And what does '(a b c) evaluate to?
> And what does '(a . b) evaluate to?
> So what does '(font . my-default-font) evaluate to?
I cannot really answer these questions. I do not know.
> What other mean to create a cons cell do you know?
Using (cons ...), that helped. Many many thanks for the help.
Rodrigo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: emacs lisp programming help
2009-01-29 18:49 ` ramestica
@ 2009-01-29 19:37 ` Pascal J. Bourguignon
0 siblings, 0 replies; 5+ messages in thread
From: Pascal J. Bourguignon @ 2009-01-29 19:37 UTC (permalink / raw)
To: help-gnu-emacs
ramestica@gmail.com writes:
> On Jan 29, 1:13 pm, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>> In general, emacs questions (even emacs lisp) would be
>
> I was about to do that but then I hesitated and look for a forum with
> the word 'lisp' on it.
>
>> What does the quote do? What does 'x evaluate to?
>> And what does '(a b c) evaluate to?
>> And what does '(a . b) evaluate to?
>> So what does '(font . my-default-font) evaluate to?
>
> I cannot really answer these questions. I do not know.
You can either know it by learning more emacs lisp,
http://www.gnu.org/software/emacs/manual/elisp.html
http://www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_toc.html
or by asking emacs itself to give you the answer.
Go in the *scratch* buffer, put it in emacs-lisp-mode
(type M-x emacs-lisp-mode RET)
then type:
'x C-u C-x C-e
'(a b c) C-u C-x C-e
'(a . b) C-u C-x C-e
'(font . my-default-font) C-u C-x C-e
and compare with:
(setq x 42) C-x C-e
x C-u C-x C-e
(a b c) C-u C-x C-e (type q to get out of the debugger)
(list 'a 'b 'c) C-u C-x C-e
(a . b)
(cons 'a 'b)
With C-x C-e, the previous s-exp is evaluated and the result is printed in the mini buffer.
With C-u C-x C-e, the result is inserted at the point in the current buffer.
An alternative is to call up the REPL: M-x ielm RET
and then you can type your emacs lisp expressions and just type RET to get the result:
'x RET
'(a b c) RET
(list 'a 'b 'c) RET
etc...
Notice that you can use C-x C-u in almost all the modes, so if you
need to insert repeatitive code, you can quickly do it by writting a
lisp expression to do so;
(dolist (color '(red green blue))
(insert (format "this->setPlane(Color::%s,other->getPlane(Color::%s));\n" color color)))
C-x C-e
inserts:
this->setPlane(Color::red,other->getPlane(Color::red));
this->setPlane(Color::green,other->getPlane(Color::green));
this->setPlane(Color::blue,other->getPlane(Color::blue));
(and you can keep the emacs lisp code in a C comment if you may need
to change it later).
>> What other mean to create a cons cell do you know?
>
> Using (cons ...), that helped. Many many thanks for the help.
>
> Rodrigo
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-29 19:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2c75e627-536b-47b7-8569-20781b041336@v39g2000pro.googlegroups.com>
2009-01-29 18:13 ` emacs lisp programming help Pascal J. Bourguignon
2009-01-29 18:49 ` ramestica
2009-01-29 19:37 ` Pascal J. Bourguignon
2006-03-16 7:15 Emacs " yeogirl
2006-03-16 7:47 ` Pascal Bourguignon
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.