unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to add button to emacs that play a elisp code
@ 2014-09-11  7:44 Renato Pontefice
  2014-09-11  8:08 ` Gian Uberto Lauri
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Renato Pontefice @ 2014-09-11  7:44 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
is it possible to add a button on my emacs that run a piece of code?
Or a combination of button.

I mean: I want to run a little elisp procedure, while I'm editing a file.

TIA

Renato


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

* Re: how to add button to emacs that play a elisp code
  2014-09-11  7:44 how to add button to emacs that play a elisp code Renato Pontefice
@ 2014-09-11  8:08 ` Gian Uberto Lauri
  2014-09-11  8:40   ` Gian Uberto Lauri
       [not found]   ` <mailman.8671.1410424828.1147.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.8670.1410422963.1147.help-gnu-emacs@gnu.org>
  2014-09-11 16:00 ` Pascal J. Bourguignon
  2 siblings, 2 replies; 30+ messages in thread
From: Gian Uberto Lauri @ 2014-09-11  8:08 UTC (permalink / raw)
  To: Renato Pontefice; +Cc: help-gnu-emacs

Renato Pontefice writes:
 > Hi,
 > is it possible to add a button on my emacs that run a piece of code?
 > Or a combination of button.

Excuse my question Renato, why a button and not a keybinding?

Consider that Emacs honours at least Super and possibly even Hyper
modifiers.

-- 
 /\           ___                                    Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
  //--\| | \|  |   Integralista GNUslamico            meaning "I can
\/                 coltivatore diretto di software       not install
     già sistemista a tempo (altrui) perso...                Debian"

Warning: gnome-config-daemon considered more dangerous than GOTO



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

* Re: how to add button to emacs that play a elisp code
       [not found] ` <mailman.8670.1410422963.1147.help-gnu-emacs@gnu.org>
@ 2014-09-11  8:24   ` Renato Pontefice
  0 siblings, 0 replies; 30+ messages in thread
From: Renato Pontefice @ 2014-09-11  8:24 UTC (permalink / raw)
  To: help-gnu-emacs

Il giorno giovedì 11 settembre 2014 10:08:54 UTC+2, Gian Uberto Lauri ha scritto:
> Renato Pontefice writes:
> 
>  > Hi,
> 
>  > is it possible to add a button on my emacs that run a piece of code?
> 
>  > Or a combination of button.
> 
> 
> 
> Excuse my question Renato, why a button and not a keybinding?
> 
> 
> 
> Consider that Emacs honours at least Super and possibly even Hyper
> 
> modifiers.
> 
> 
> 
> -- 
> 
>  /\           ___                                    Ubuntu: ancient
> 
> /___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
> 
>   //--\| | \|  |   Integralista GNUslamico            meaning "I can
> 
> \/                 coltivatore diretto di software       not install
> 
>      già sistemista a tempo (altrui) perso...                Debian"
> 
> 
> 
> Warning: gnome-config-daemon considered more dangerous than GOTO

Yes! of course! keybinding too! (I've called it >  > Or a combination of button.)

How can I do? 

Renato


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

* Re: how to add button to emacs that play a elisp code
  2014-09-11  8:08 ` Gian Uberto Lauri
@ 2014-09-11  8:40   ` Gian Uberto Lauri
  2014-09-11 12:17     ` Stefan Monnier
       [not found]   ` <mailman.8671.1410424828.1147.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 30+ messages in thread
From: Gian Uberto Lauri @ 2014-09-11  8:40 UTC (permalink / raw)
  To: help-gnu-emacs

My apologies for breaking the threading, I lost the original message I
am replying to.

In Emacs you can have global keybindings (that are active no matter
what is the current buffer) and local ones (active only in the buffers
they are defined for).

The functions to use are

(global-set-key [(super meta i)] 
                '(lambda () 
                   (interactive)
                   (ispell-change-dictionary "italian")))

(this example changes the ispell dictionary to Italian and is bound to
super meta i)

the other function is

(local-set-key [?\s-w] 'jde-complete)

This is another syntax to use the "super" modifier.

At this time the 'standard' us(altgr-intl) X11 keyboard layout only
gives me Super, but I plan to hack that to have hyper back.

Despite not this standard, these modifiers from the space cadet
keyboard give you plenty of quick-to-access keystroke that do not need
a prefix you can use for your own customization.

-- 
 /\           ___                                    Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
  //--\| | \|  |   Integralista GNUslamico            meaning "I can
\/                 coltivatore diretto di software       not install
     già sistemista a tempo (altrui) perso...                Debian"

Warning: gnome-config-daemon considered more dangerous than GOTO



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

* Re: how to add button to emacs that play a elisp code
  2014-09-11  8:40   ` Gian Uberto Lauri
@ 2014-09-11 12:17     ` Stefan Monnier
  2014-09-11 12:22       ` Gian Uberto Lauri
  0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2014-09-11 12:17 UTC (permalink / raw)
  To: help-gnu-emacs

> (global-set-key [(super meta i)] 
>                 '(lambda () 
>                    (interactive)
>                    (ispell-change-dictionary "italian")))

Please please prettty please don't quote your lambdas!


        Stefan




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

* Re: how to add button to emacs that play a elisp code
  2014-09-11 12:17     ` Stefan Monnier
@ 2014-09-11 12:22       ` Gian Uberto Lauri
  2014-09-11 12:35         ` Stefan Monnier
       [not found]         ` <mailman.8685.1410439222.1147.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 30+ messages in thread
From: Gian Uberto Lauri @ 2014-09-11 12:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier writes:
 > > (global-set-key [(super meta i)] 
 > >                 '(lambda () 
 > >                    (interactive)
 > >                    (ispell-change-dictionary "italian")))
 > 
 > Please please prettty please don't quote your lambdas!

?????

-- 
 /\           ___                                    Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
  //--\| | \|  |   Integralista GNUslamico            meaning "I can
\/                 coltivatore diretto di software       not install
     già sistemista a tempo (altrui) perso...                Debian"

Warning: gnome-config-daemon considered more dangerous than GOTO



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

* Re: how to add button to emacs that play a elisp code
  2014-09-11 12:22       ` Gian Uberto Lauri
@ 2014-09-11 12:35         ` Stefan Monnier
  2014-09-11 12:46           ` Gian Uberto Lauri
       [not found]         ` <mailman.8685.1410439222.1147.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2014-09-11 12:35 UTC (permalink / raw)
  To: help-gnu-emacs

>> Please please prettty please don't quote your lambdas!
> ?????

Write it:

   (global-set-key [(super meta i)] 
                   (lambda () 
                     (interactive)
                     (ispell-change-dictionary "italian")))


-- Stefan




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

* Re: how to add button to emacs that play a elisp code
  2014-09-11 12:35         ` Stefan Monnier
@ 2014-09-11 12:46           ` Gian Uberto Lauri
  0 siblings, 0 replies; 30+ messages in thread
From: Gian Uberto Lauri @ 2014-09-11 12:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier writes:
 > >> Please please prettty please don't quote your lambdas!
 > > ?????
 > 
 > Write it:
 > 
 >    (global-set-key [(super meta i)] 
 >                    (lambda () 
 >                      (interactive)
 >                      (ispell-change-dictionary "italian")))

Oh, thank you! *NOW* I understand your words, sadly I can't use LISP
this much, I misinterpreted the word quote.

Thank you very much

-- 
 /\           ___                                    Ubuntu: ancient
/___/\_|_|\_|__|___Gian Uberto Lauri_____               African word
  //--\| | \|  |   Integralista GNUslamico            meaning "I can
\/                 coltivatore diretto di software       not install
     già sistemista a tempo (altrui) perso...                Debian"

Warning: gnome-config-daemon considered more dangerous than GOTO



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

* Re: how to add button to emacs that play a elisp code
  2014-09-11  7:44 how to add button to emacs that play a elisp code Renato Pontefice
  2014-09-11  8:08 ` Gian Uberto Lauri
       [not found] ` <mailman.8670.1410422963.1147.help-gnu-emacs@gnu.org>
@ 2014-09-11 16:00 ` Pascal J. Bourguignon
  2 siblings, 0 replies; 30+ messages in thread
From: Pascal J. Bourguignon @ 2014-09-11 16:00 UTC (permalink / raw)
  To: help-gnu-emacs

Renato Pontefice <renato.pontefice@gmail.com> writes:

> Hi,
> is it possible to add a button on my emacs that run a piece of code?
> Or a combination of button.
>
> I mean: I want to run a little elisp procedure, while I'm editing a file.

So you've seen global-set-key to configure a key or combination of keys
(key chord) to call up an elisp command.

But you can also insert buttons in buffers to run some elisp code:

(let ((start (point)))
  (insert "Hello")
  (let ((end (point)))
    (make-button start end 'action (lambda (&rest args) (message "world!")))))

When you evaluate this expression, it inserts the text Hello as a
button.  If you move to this button and type RET, or middle-click on it,
then the action function is called, which in this case will display
world! in the minibuffer.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: how to add button to emacs that play a elisp code
       [not found]   ` <mailman.8671.1410424828.1147.help-gnu-emacs@gnu.org>
@ 2014-09-11 21:06     ` Emanuel Berg
  0 siblings, 0 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-11 21:06 UTC (permalink / raw)
  To: help-gnu-emacs

"Gian Uberto Lauri" <saint@eng.it> writes:

> In Emacs you can have global keybindings (that are
> active no matter what is the current buffer) and
> local ones (active only in the buffers they are
> defined for).

Almost!

The global map is always present, yes.

But if there is a mode map, and you set the global map
for key K, and K is defined in the mode map as well,
and then you hit K, you get the mode K, not the
"global" K.

This can make for a fair bit of annoyance if you (like
me) want to have a lot of (truly) global keys (i.e.,
keys that are the same everywhere).

I don't know what the standard approach is.

Either, you can rebind all those mode maps. Those can
be quite a few. (But it can be automatized with
functions that accepts the maps as arguments.)

Or you can set the global map to the keys you want, and
then have those keys set to nil in the mode maps.

I have experimented a lot with this (in various ways),
and all is in:

http://user.it.uu.se/~embe8573/conf/emacs-init/global-keys.el

- it works, but I wouldn't be surprised if there are
other ways to do it as well, which may be better or
worse.

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
       [not found]         ` <mailman.8685.1410439222.1147.help-gnu-emacs@gnu.org>
@ 2014-09-11 21:15           ` Emanuel Berg
  2014-09-11 23:42             ` Pascal J. Bourguignon
  0 siblings, 1 reply; 30+ messages in thread
From: Emanuel Berg @ 2014-09-11 21:15 UTC (permalink / raw)
  To: help-gnu-emacs

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

>>> Please please prettty please don't quote your
>>> lambdas!
>>
>> ?????
>
> Write it:
>
>    (global-set-key [(super meta i)] (lambda ()
> (interactive) (ispell-change-dictionary "italian")))

It is probably easier to remember if you exilian why.

With the quote, it is a list, with the first element
lambda, the second element an empty list, and so on.

    '(1 2 3) ; the list (1 2 3)
(list 1 2 3) ; the same

If it is a function, the lambda, it can be optimized
when byte-compiled. In practice, I kind of think the
OPs lambda won't benefit from this (?), but sure, aim
to get as much of it right from day one, and practice
that on simple things just as well as on difficult
things.

Right?

By the way, I thought I would make it even more
pedagogical with `functionp' and `listp', but:

(functionp '(lambda () (interactive) 1)) ; t
(listp      (lambda () (interactive) 1)) ; t

It is as they say, you should stop when you are
ahead...

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-11 21:15           ` Emanuel Berg
@ 2014-09-11 23:42             ` Pascal J. Bourguignon
  2014-09-12  0:05               ` Emanuel Berg
  0 siblings, 1 reply; 30+ messages in thread
From: Pascal J. Bourguignon @ 2014-09-11 23:42 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>>> Please please prettty please don't quote your
>>>> lambdas!
>>>
>>> ?????
>>
>> Write it:
>>
>>    (global-set-key [(super meta i)] (lambda ()
>> (interactive) (ispell-change-dictionary "italian")))
>
> It is probably easier to remember if you exilian why.
>
> With the quote, it is a list, with the first element
> lambda, the second element an empty list, and so on.
>
>     '(1 2 3) ; the list (1 2 3)
> (list 1 2 3) ; the same

No, not the same!


(defun f () '(1 2 3))
(defun g () (list 1 2 3))

(eq (f) (f)) --> t
(eq (g) (g)) --> nil

list always return a new list or nil.
quote always return the very same object it has in argument.

It's not the same at all!


> By the way, I thought I would make it even more
> pedagogical with `functionp' and `listp', but:
>
> (functionp '(lambda () (interactive) 1)) ; t
> (listp      (lambda () (interactive) 1)) ; t

This is wrong also.


(defun h ()
 (list (functionp '(lambda () (interactive) 1))
       (listp      (lambda () (interactive) 1))))
(h) --> (t t)
(byte-compile 'h)
(h) --> (t nil)


It just happens that for the emacs lisp interpreter, a lambda expression
is a function, and therefore in emacs lisp, lambda is a macro that
returns a lambda expression and it works.  But once compiled it doesn't
work anymore.


And personnaly, I'd promote a more common lisp, therefore I would avoid
using those specific particularities, since in other Common Lisp
implementations, functions are entirely distinct from lists.


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: how to add button to emacs that play a elisp code
  2014-09-11 23:42             ` Pascal J. Bourguignon
@ 2014-09-12  0:05               ` Emanuel Berg
  2014-09-12  0:23                 ` Michael Heerdegen
                                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-12  0:05 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> list always return a new list or nil. quote always
> return the very same object it has in argument.
>
> It's not the same at all!

Of course list is not the same as quote in general.

But those examples are the same in the sense that when
I evaluate them I get the same result. You can try that
yourself, here:

'(1 2 3)        ; (1 2 3)
(quote (1 2 3)) ; same
(list 1 2 3)    ; same

>> By the way, I thought I would make it even more
>> pedagogical with `functionp' and `listp', but:
>> (functionp '(lambda () (interactive) 1)) ; t (listp
>> (lambda () (interactive) 1)) ; t
>
> This is wrong also.

"Wrong"? Those are the results I get. Here:

(functionp '(lambda () (interactive) 1)) ; t
(listp      (lambda () (interactive) 1)) ; t

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  0:05               ` Emanuel Berg
@ 2014-09-12  0:23                 ` Michael Heerdegen
       [not found]                 ` <mailman.8717.1410481417.1147.help-gnu-emacs@gnu.org>
  2014-09-13 21:28                 ` Pascal J. Bourguignon
  2 siblings, 0 replies; 30+ messages in thread
From: Michael Heerdegen @ 2014-09-12  0:23 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> '(1 2 3)        ; (1 2 3)
> (quote (1 2 3)) ; same
> (list 1 2 3)    ; same

I think what Pascal means is that these are not the "same" in the sense
that when you replace one of these expressions with the other in a
program, the result after evaluation may change.  It's important to
state that, because this issue is a common pitfall in Lisp.

Michael.




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

* Re: how to add button to emacs that play a elisp code
       [not found]                 ` <mailman.8717.1410481417.1147.help-gnu-emacs@gnu.org>
@ 2014-09-12  0:50                   ` Emanuel Berg
  2014-09-12  1:19                     ` Michael Heerdegen
       [not found]                     ` <mailman.8719.1410484774.1147.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-12  0:50 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> I think what Pascal means is that these are not the
> "same" in the sense that when you replace one of
> these expressions with the other in a program, the
> result after evaluation may change. It's important to
> state that, because this issue is a common pitfall in
> Lisp.

Aha, yes, that property even has a name - something
that can be placed anywhere and still produce the same
result, even if invoked repeatedly...?

How common this pitfall is in Lisp one has to wonder
though... do you have an example? I never had a
problem, but perhaps that is because I only recently
started to byte-compile all my code.

Not that I experienced anything, actually, save for the
warning messages on compilation that perhaps served to
clean up the code.

And the system feels a tiny bit faster (perhaps my
imagination).

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  0:50                   ` Emanuel Berg
@ 2014-09-12  1:19                     ` Michael Heerdegen
  2014-09-12 14:52                       ` Drew Adams
       [not found]                     ` <mailman.8719.1410484774.1147.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 30+ messages in thread
From: Michael Heerdegen @ 2014-09-12  1:19 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> How common this pitfall is in Lisp one has to wonder
> though... do you have an example?

Using quoted lists in your program, you may get a mysteriously
self-modifying behavior:


(defun 1-2-rest (&rest elements)
  "Return a list of 1, 2 and the ELEMENTS."
  (nconc '(1 2) elements))

(1-2-rest 3)
  ==> (1 2 3)

(1-2-rest 'a)
  ==> (1 2 3 a)    ;; Oops!


This happens because the list '(1 2) is constructed by the lisp reader,
and the resulting object becomes part of your program.  Compiling isn't
involved, btw.


OTOH:

(defun 1-2-rest (&rest elements)
  "Return a list of 1, 2 and the ELEMENTS."
  (nconc (list 1 2) elements))

(1-2-rest 3)
  ==> (1 2 3)

(1-2-rest 'a)
  ==> (1 2 a)    ;; Better!

Now, the list (1 2) is constructed at run-time.  This definition leads
to a quite different program.


You may argue that you can avoid destructive operations like `nconc' in
your code to prevent that problem.  But that isn't enough either: when
you pass your list to some function you didn't define yourself (e.g. a
function that is part of Emacs), it is passed as reference (as usual in
Lisp), and it may be modified by that function by side effect, so that
your program "changes" too.

If you are not aware of that problem, it probably won't bite you often,
but when it does, you'll need a lot of time to find out what's actually
going on.

BTW, this "effect" can also be used constructively, it's not "harmful"
per se.


Michael.




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

* Re: how to add button to emacs that play a elisp code
       [not found]                     ` <mailman.8719.1410484774.1147.help-gnu-emacs@gnu.org>
@ 2014-09-12  2:07                       ` Emanuel Berg
  2014-09-12  7:44                         ` Renato Pontefice
  0 siblings, 1 reply; 30+ messages in thread
From: Emanuel Berg @ 2014-09-12  2:07 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> You may argue that you can avoid destructive
> operations like `nconc' in your code to prevent that
> problem.

I was just about to say that - almost. While I don't
think side effects are bad by definition, and I
disklike the whole functional paradigm crusade with the
Haskell hysteria and all, in practise it makes sense
most of the time.

But that is more related to your specific example than
to the problem, right?

> But that isn't enough either: when you pass your list
> to some function you didn't define yourself (e.g. a
> function that is part of Emacs), it is passed as
> reference (as usual in Lisp), and it may be modified
> by that function by side effect, so that your program
> "changes" too.
>
> If you are not aware of that problem, it probably
> won't bite you often, but when it does, you'll need a
> lot of time to find out what's actually going on.
>
> BTW, this "effect" can also be used constructively,
> it's not "harmful" per se.

No, I have lots of quoted, and even backquoted stuff,
which would have showed its harmful side by now, so I
suppose I have been using it either "constructively" or
where it doesn't matter which.

By the way - computer science silly buzzword:
idempotence, or "referential transparency".

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  2:07                       ` Emanuel Berg
@ 2014-09-12  7:44                         ` Renato Pontefice
  2014-09-12 10:15                           ` Renato Pontefice
  0 siblings, 1 reply; 30+ messages in thread
From: Renato Pontefice @ 2014-09-12  7:44 UTC (permalink / raw)
  To: help-gnu-emacs

Il giorno venerdì 12 settembre 2014 04:07:37 UTC+2, Emanuel Berg ha scritto:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
> 
> 
> > You may argue that you can avoid destructive
> 
> > operations like `nconc' in your code to prevent that
> 
> > problem.
> 
> 
> 
> I was just about to say that - almost. While I don't
> 
> think side effects are bad by definition, and I
> 
> disklike the whole functional paradigm crusade with the
> 
> Haskell hysteria and all, in practise it makes sense
> 
> most of the time.
> 
> 
> 
> But that is more related to your specific example than
> 
> to the problem, right?
> 
> 
> 
> > But that isn't enough either: when you pass your list
> 
> > to some function you didn't define yourself (e.g. a
> 
> > function that is part of Emacs), it is passed as
> 
> > reference (as usual in Lisp), and it may be modified
> 
> > by that function by side effect, so that your program
> 
> > "changes" too.
> 
> >
> 
> > If you are not aware of that problem, it probably
> 
> > won't bite you often, but when it does, you'll need a
> 
> > lot of time to find out what's actually going on.
> 
> >
> 
> > BTW, this "effect" can also be used constructively,
> 
> > it's not "harmful" per se.
> 
> 
> 
> No, I have lots of quoted, and even backquoted stuff,
> 
> which would have showed its harmful side by now, so I
> 
> suppose I have been using it either "constructively" or
> 
> where it doesn't matter which.
> 
> 
> 
> By the way - computer science silly buzzword:
> 
> idempotence, or "referential transparency".
> 
> 
> 
> -- 
> 
> underground experts united

Hi,
I've read he most part of the thread, but, 
as one who does not know elisp,I got lost in the debate :-(
wich is the prob on the execution of my (your) code, pressing the key:

(global-set-key (kbd "M-A") 'backward-word) ; Alt+Shift+a
(while (and (not (eobp))
            (search-forward "[-" nil 'move))
  (skip-chars-forward "A-Z")
  (unless (looking-at "-]")
    (message "Problem found, please fix and hit C-M-c to continue")
    (recursive-edit))))

?

thank you

Renato


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  7:44                         ` Renato Pontefice
@ 2014-09-12 10:15                           ` Renato Pontefice
  2014-09-12 19:33                             ` Emanuel Berg
  0 siblings, 1 reply; 30+ messages in thread
From: Renato Pontefice @ 2014-09-12 10:15 UTC (permalink / raw)
  To: help-gnu-emacs

Il giorno venerdì 12 settembre 2014 09:44:07 UTC+2, Renato Pontefice ha scritto:
> Il giorno venerdì 12 settembre 2014 04:07:37 UTC+2, Emanuel Berg ha scritto:
> 
> > Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
> > 
> 
> > 
> 
> > 
> 
> > > You may argue that you can avoid destructive
> 
> > 
> 
> > > operations like `nconc' in your code to prevent that
> 
> > 
> 
> > > problem.
> 
> > 
> 
> > 
> 
> > 
> 
> > I was just about to say that - almost. While I don't
> 
> > 
> 
> > think side effects are bad by definition, and I
> 
> > 
> 
> > disklike the whole functional paradigm crusade with the
> 
> > 
> 
> > Haskell hysteria and all, in practise it makes sense
> 
> > 
> 
> > most of the time.
> 
> > 
> 
> > 
> 
> > 
> 
> > But that is more related to your specific example than
> 
> > 
> 
> > to the problem, right?
> 
> > 
> 
> > 
> 
> > 
> 
> > > But that isn't enough either: when you pass your list
> 
> > 
> 
> > > to some function you didn't define yourself (e.g. a
> 
> > 
> 
> > > function that is part of Emacs), it is passed as
> 
> > 
> 
> > > reference (as usual in Lisp), and it may be modified
> 
> > 
> 
> > > by that function by side effect, so that your program
> 
> > 
> 
> > > "changes" too.
> 
> > 
> 
> > >
> 
> > 
> 
> > > If you are not aware of that problem, it probably
> 
> > 
> 
> > > won't bite you often, but when it does, you'll need a
> 
> > 
> 
> > > lot of time to find out what's actually going on.
> 
> > 
> 
> > >
> 
> > 
> 
> > > BTW, this "effect" can also be used constructively,
> 
> > 
> 
> > > it's not "harmful" per se.
> 
> > 
> 
> > 
> 
> > 
> 
> > No, I have lots of quoted, and even backquoted stuff,
> 
> > 
> 
> > which would have showed its harmful side by now, so I
> 
> > 
> 
> > suppose I have been using it either "constructively" or
> 
> > 
> 
> > where it doesn't matter which.
> 
> > 
> 
> > 
> 
> > 
> 
> > By the way - computer science silly buzzword:
> 
> > 
> 
> > idempotence, or "referential transparency".
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > underground experts united
> 
> 
> 
> Hi,
> 
> I've read he most part of the thread, but, 
> 
> as one who does not know elisp,I got lost in the debate :-(
> 
> wich is the prob on the execution of my (your) code, pressing the key:
> 
> 
> 
> (global-set-key (kbd "M-A") 'backward-word) ; Alt+Shift+a
> 
> (while (and (not (eobp))
> 
>             (search-forward "[-" nil 'move))
> 
>   (skip-chars-forward "A-Z")
> 
>   (unless (looking-at "-]")
> 
>     (message "Problem found, please fix and hit C-M-c to continue")
> 
>     (recursive-edit))))
> 
> 
> 
> ?
> 
> 
> 
> thank you
> 
> 
> 
> Renato

Hi, Ive found, that maybe, there is another parenthesis / maybe the last one,

I-ve erased it and emacs start without error, but if I press Alt/Shift/ A, nothing happens.

What-s wrong? 

Renato


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  1:19                     ` Michael Heerdegen
@ 2014-09-12 14:52                       ` Drew Adams
  0 siblings, 0 replies; 30+ messages in thread
From: Drew Adams @ 2014-09-12 14:52 UTC (permalink / raw)
  To: help-gnu-emacs

This reply does not directly address the OP question -
just an FYI about something somewhat related.

With Bookmark+ you can have a bookmark that does pretty much
anything, including invoke arbitrary Lisp code.

Command `bmkp-insert-bookmark-link' creates a link (button, if
you prefer) on any text (e.g. the region) that, when followed,
invokes the bookmark (jumps somewhere or does something else).
Hitting `?' or double-clicking the link shows the bookmark
info in *Help*.

[If you also use library font-lock+.el then the links/buttons
are highlighted (with face `link') even in font-locked buffers.
See Emacs bug #18367 about such highlighting.]

http://www.emacswiki.org/BookmarkPlus



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

* Re: how to add button to emacs that play a elisp code
  2014-09-12 10:15                           ` Renato Pontefice
@ 2014-09-12 19:33                             ` Emanuel Berg
  0 siblings, 0 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-12 19:33 UTC (permalink / raw)
  To: help-gnu-emacs

Renato Pontefice <renato.pontefice@gmail.com> writes:

> Hi, Ive found, that maybe, there is another
> parenthesis / maybe the last one,
>
> I-ve erased it and emacs start without error, but if
> I press Alt/Shift/ A, nothing happens.

OK, let's take this from the beginning, as this thread
spun out a bit.

What do you want to do? Do you want to set M-A to do
`backward-word'?

M-A is the Emacs notation for Alt, Shift, and a.
Because Emacs relies heavily on shortcuts, that notation
(M-A) is better as it is shorter to type and more
compact to read.

It may be a bad idea to use M-A for `backward-word'.
M-a (note lowercase "a") is already
`backward-sentence', and you don't want to get those
mixed up.

Also, backward-word is something you do all the time.
By default, backward-word is `M-b'. Most people would
say that M-b is better than M-a for at least two
reasons: 1) M-b involves two keys, and M-A three. 2)
M-b involves both hands, and such commands are
generally speaking easier to type: compare, from the
Unix/Linux world: ls, cp, mv, ps, du...

But, after all is said and done, if you still want
`M-A', this will do it:

(global-set-key (kbd "M-A") 'backward-word)

Unless there is a mode or local keybinding that is also
`M-A'. But, for the reasons above, I think that is
unlikely, so M-A should work after you evaluate the
above Elisp.

If it doesn't, use `C-h k' and hit `M-A'. What does it
say?

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-12  0:05               ` Emanuel Berg
  2014-09-12  0:23                 ` Michael Heerdegen
       [not found]                 ` <mailman.8717.1410481417.1147.help-gnu-emacs@gnu.org>
@ 2014-09-13 21:28                 ` Pascal J. Bourguignon
  2014-09-14  2:30                   ` Rusi
  2014-09-14 18:11                   ` Emanuel Berg
  2 siblings, 2 replies; 30+ messages in thread
From: Pascal J. Bourguignon @ 2014-09-13 21:28 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> "Pascal J. Bourguignon" <pjb@informatimago.com> writes:
>
>> list always return a new list or nil. quote always
>> return the very same object it has in argument.
>>
>> It's not the same at all!
>
> Of course list is not the same as quote in general.
>
> But those examples are the same in the sense that when
> I evaluate them I get the same result. You can try that
> yourself, here:
>
> '(1 2 3)        ; (1 2 3)
> (quote (1 2 3)) ; same
> (list 1 2 3)    ; same

No. That's the point.  I'm using clhs definition of same(2), since elisp
info doesn't provide a glossary.  

    same adj. 1. (of objects under a specified predicate) indistinguishable
    by that predicate. ``The symbol car, the string "car", and the string
    "CAR" are the same under string-equal''. 2. (of objects if no predicate
    is implied by context) indistinguishable by eql. Note that eq might be
    capable of distinguishing some numbers and characters which eql cannot
    distinguish, but the nature of such, if any, is
    implementation-dependent. Since eq is used only rarely in this
    specification, eql is the default predicate when none is mentioned
    explicitly. ``The conses returned by two successive calls to cons are
    never the same.'' 3. (of types) having the same set of elements; that
    is, each type is a subtype of the others. ``The types specified by
    (integer 0 1), (unsigned-byte 1), and bit are the same.'' 


But notice that the same meaning seems to be used rather consistently in
the elisp info, for example in section "5.6.3 Functions that Rearrange
Lists", the description of sort says:

     Sorting does not change the CARs of the cons cells in LIST; the
     cons cell that originally contained the element `a' in LIST still
     has `a' in its CAR after sorting, but it now appears in a
     different position in the list due to the change of CDRs.  For
     example:

          (setq nums '(1 3 2 6 5 4 0))
               => (1 3 2 6 5 4 0)
          (sort nums '<)
               => (0 1 2 3 4 5 6)
          nums
               => (1 2 3 4 5 6)

     *Warning*: Note that the list in `nums' no longer contains 0; this
     is the same cons cell that it was before, but it is no longer the
     first one in the list.  Don't assume a variable that formerly held
     the argument now holds the entire sorted list!  Instead, save the
     result of `sort' and use that.  Most often we store the result
     back into the variable that held the original list:



>>> By the way, I thought I would make it even more
>>> pedagogical with `functionp' and `listp', but:
>>> (functionp '(lambda () (interactive) 1)) ; t (listp
>>> (lambda () (interactive) 1)) ; t
>>
>> This is wrong also.
>
> "Wrong"? Those are the results I get. Here:
>
> (functionp '(lambda () (interactive) 1)) ; t
> (listp      (lambda () (interactive) 1)) ; t

I've shown you that you get this result by pure chance, just because it
happens that you didn't compile that code!

Read the whole messages and don't truncate them indiscriminately!

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


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

* Re: how to add button to emacs that play a elisp code
  2014-09-13 21:28                 ` Pascal J. Bourguignon
@ 2014-09-14  2:30                   ` Rusi
  2014-09-14  4:18                     ` Rusi
  2014-09-14 18:16                     ` Emanuel Berg
  2014-09-14 18:11                   ` Emanuel Berg
  1 sibling, 2 replies; 30+ messages in thread
From: Rusi @ 2014-09-14  2:30 UTC (permalink / raw)
  To: help-gnu-emacs

On Sunday, September 14, 2014 2:58:44 AM UTC+5:30, Pascal J. Bourguignon wrote:
> Emanuel Berg writes:

> > "Pascal J. Bourguignon" writes:
> >> list always return a new list or nil. quote always
> >> return the very same object it has in argument.
> >> It's not the same at all!
> > Of course list is not the same as quote in general.
> > But those examples are the same in the sense that when
> > I evaluate them I get the same result. You can try that
> > yourself, here:
> > '(1 2 3)        ; (1 2 3)
> > (quote (1 2 3)) ; same
> > (list 1 2 3)    ; same

> No. That's the point.  I'm using clhs definition of same(2), since elisp
> info doesn't provide a glossary.  

>     same adj. 1. (of objects under a specified predicate) indistinguishable
>     by that predicate. ``The symbol car, the string "car", and the string
>     "CAR" are the same under string-equal''. 2. (of objects if no predicate
>     is implied by context) indistinguishable by eql. Note that eq might be
>     capable of distinguishing some numbers and characters which eql cannot
>     distinguish, but the nature of such, if any, is
>     implementation-dependent. Since eq is used only rarely in this
>     specification, eql is the default predicate when none is mentioned
>     explicitly. ``The conses returned by two successive calls to cons are
>     never the same.'' 3. (of types) having the same set of elements; that
>     is, each type is a subtype of the others. ``The types specified by
>     (integer 0 1), (unsigned-byte 1), and bit are the same.'' 

> But notice that the same meaning seems to be used rather consistently in
> the elisp info, for example in section "5.6.3 Functions that Rearrange
> Lists", the description of sort says:

>      Sorting does not change the CARs of the cons cells in LIST; the
>      cons cell that originally contained the element `a' in LIST still
>      has `a' in its CAR after sorting, but it now appears in a
>      different position in the list due to the change of CDRs.  For
>      example:

>           (setq nums '(1 3 2 6 5 4 0))
>                => (1 3 2 6 5 4 0)
>           (sort nums '<)
>                => (0 1 2 3 4 5 6)
>           nums
>                => (1 2 3 4 5 6)

>      *Warning*: Note that the list in `nums' no longer contains 0; this
>      is the same cons cell that it was before, but it is no longer the
>      first one in the list.  Don't assume a variable that formerly held
>      the argument now holds the entire sorted list!  Instead, save the
>      result of `sort' and use that.  Most often we store the result
>      back into the variable that held the original list:


> >>> By the way, I thought I would make it even more
> >>> pedagogical with `functionp' and `listp', but:
> >>> (functionp '(lambda () (interactive) 1)) ; t (listp
> >>> (lambda () (interactive) 1)) ; t
> >> This is wrong also.
> > "Wrong"? Those are the results I get. Here:
> > (functionp '(lambda () (interactive) 1)) ; t
> > (listp      (lambda () (interactive) 1)) ; t

> I've shown you that you get this result by pure chance, just because it
> happens that you didn't compile that code!

> Read the whole messages and don't truncate them indiscriminately!

Ive always found that talking about the semantics of lisp (as compared
to more modern functional languages) is quite tricky because of quote.

Here is Wadler spelling out the problem
http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf

I often get into arguments on the python list because I find python's
'is' operator (roughly lisp's 'eq) a terrible name in that it
insidiously coincides identity in the philosophical sense with pointer
identity.

Here http://blog.languager.org/2013/08/applying-si-on-sicp.html
is my own take on this and why even the inventors of scheme seem to 
have missed some key points in scheme (lisp) philosophy.


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

* Re: how to add button to emacs that play a elisp code
  2014-09-14  2:30                   ` Rusi
@ 2014-09-14  4:18                     ` Rusi
  2014-09-14 18:16                     ` Emanuel Berg
  1 sibling, 0 replies; 30+ messages in thread
From: Rusi @ 2014-09-14  4:18 UTC (permalink / raw)
  To: help-gnu-emacs

On Sunday, September 14, 2014 8:00:18 AM UTC+5:30, Rusi wrote:

> I often get into arguments on the python list because I find python's
> 'is' operator (roughly lisp's 'eq) a terrible name in that it
> insidiously coincides identity in the philosophical sense with pointer
> identity.

Whoops! A typo that adds more confusion than clarity:

That 'eq looks like a lisp-quoted-eq.

I meant an English-quoted-eq -- 'eq' !



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

* Re: how to add button to emacs that play a elisp code
  2014-09-13 21:28                 ` Pascal J. Bourguignon
  2014-09-14  2:30                   ` Rusi
@ 2014-09-14 18:11                   ` Emanuel Berg
  2014-09-15  5:48                     ` Alex Kost
       [not found]                     ` <mailman.8874.1410760111.1147.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-14 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> No. That's the point. I'm using clhs definition of
> same(2), since elisp info doesn't provide a glossary.

(Hint. This message will be more pleasant to read in
Emacs-Lisp mode because of the
`font-lock-constant-face' and
`font-lock-comment-face'.)

;; Here are the ways I know of to determine equality.
;; I didn't include = as that doesn't work on lists
;; (if I had, I might as well have included
;; `string-equal'/`string=').

;; Feel free to provide any additional ways that may
;; exist.

;; When I wrote "same", I did it informally. Even so,
;; I appreciate defining that according to the
;; scientific method.

;; OK:

;; 1. evaluation

(list 1 2 3) ; (1 2 3)
'(1 2 3)     ; (1 2 3)

(setq ll (list 1 2 3))
(setq lq '(1 2 3))

;; 2. eq

(eq ll lq)                     ; nil; but, on the other hand:
(eq (list 1 2 3) (list 1 2 3)) ; nil
(eq '(1 2 3) '(1 2 3))         ; nil

;; 3. eql

(eql ll lq)                     ; nil; but, again:
(eql (list 1 2 3) (list 1 2 3)) ; nil
(eql '(1 2 3) '(1 2 3))         ; nil

;; 4. equal

(equal ll lq)                     ; t
(equal (list 1 2 3) (list 1 2 3)) ; t
(equal '(1 2 3) '(1 2 3))         ; t
(equal (list 1 2 3) '(1 2 3))     ; t

;; Fallout:

;; It is the same according to evaluation. It is not
;; the same according to `eq' and `eql'; on the other
;; hand those don't report the same even for identical
;; data, which humans intuitively consider the same.
;; It is the same according to `equal' (which also
;; report the same for identical data; i.e., is closer
;; than `eq' and `eql' to the way humans think).

;; Conclusion:

;; 1. According to the computer, it is not always the
;;    same, but as often, it is.

;; 2. It is the same when using methods that (in other
;;    cases as well) correspond more closely to the
;;    way humans think.

;; 3. Because I used the word like a human, one would
;;    think I used it correctly because of (2). But,
;;    because I used it in the context of computers,
;;    because of (1), I'll settle for a draw.

;; :)

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-14  2:30                   ` Rusi
  2014-09-14  4:18                     ` Rusi
@ 2014-09-14 18:16                     ` Emanuel Berg
  1 sibling, 0 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-14 18:16 UTC (permalink / raw)
  To: help-gnu-emacs

Rusi <rustompmody@gmail.com> writes:

> Ive always found that talking about the semantics of
> lisp (as compared to more modern functional
> languages) is quite tricky because of quote.
>
> Here is Wadler spelling out the problem
> http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf
>
> I often get into arguments on the python list because
> I find python's 'is' operator (roughly lisp's 'eq) a
> terrible name in that it insidiously coincides
> identity in the philosophical sense with pointer
> identity.
>
> Here
> http://blog.languager.org/2013/08/applying-si-on-sicp.html
> is my own take on this and why even the inventors of
> scheme seem to have missed some key points in scheme
> (lisp) philosophy.

Because Pascal told me to read, it's only fair I tell
you not to read but instead to write code. And instead
of saying you are writing code, why don't you post it
on this list? And then you can tell Pascal he should...
uh, I don't know?

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-14 18:11                   ` Emanuel Berg
@ 2014-09-15  5:48                     ` Alex Kost
       [not found]                     ` <mailman.8874.1410760111.1147.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 30+ messages in thread
From: Alex Kost @ 2014-09-15  5:48 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg (2014-09-14 22:11 +0400) wrote:

> "Pascal J. Bourguignon" <pjb@informatimago.com> writes:
>
>> No. That's the point. I'm using clhs definition of
>> same(2), since elisp info doesn't provide a glossary.
>
> (Hint. This message will be more pleasant to read in
> Emacs-Lisp mode because of the
> `font-lock-constant-face' and
> `font-lock-comment-face'.)

[...]

A comment to your hint.

As you are using Gnus, you may just attach your elisp file (or buffer)
to make it be highlighted inline: "C-c RET f" (or "C-c RET b") and
choose "application/emacs-lisp" type.

Another way is including org source blocks.




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

* Re: how to add button to emacs that play a elisp code
       [not found]                     ` <mailman.8874.1410760111.1147.help-gnu-emacs@gnu.org>
@ 2014-09-15 22:45                       ` Emanuel Berg
  2014-09-16  4:55                         ` Alex Kost
       [not found]                         ` <mailman.8956.1410843332.1147.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-15 22:45 UTC (permalink / raw)
  To: help-gnu-emacs

Alex Kost <alezost@gmail.com> writes:

> A comment to your hint.
>
> As you are using Gnus, you may just attach your elisp
> file (or buffer) to make it be highlighted inline:
> "C-c RET f" (or "C-c RET b") and choose
> "application/emacs-lisp" type.

I'm using Gnus - but I'm not the one reading the post.

How will that make it look for people not using Gnus?

I like to have my posts totally client-agnostic. But if
it doesn't bloat the post with too much
incomprehensible metadata for the non-Gnuser, I'll
consider it - why not encourage people to switch to
Gnus?

OK - here is the attached Elisp:

Wait - `C-c RET' is undefined, it says.

Do you mean I (or any Gnuser reading such messages)
should use your keystrokes in message-mode to get the
highlight? But there, `C-c RET' is `gnus-article-mail'!
What are the names of the commands?

> Another way is including org source blocks.

You mean like this:

#+BEGIN_SRC emacs-lisp
  (defun org-xor (a b)
     "Exclusive or."
     (if a (not b) b))
#+END_SRC

Org manual example from:

http://orgmode.org/manual/Working-With-Source-Code.html

I have the same concerns for that method, but let's see
how that works, as well.

-- 
underground experts united


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

* Re: how to add button to emacs that play a elisp code
  2014-09-15 22:45                       ` Emanuel Berg
@ 2014-09-16  4:55                         ` Alex Kost
       [not found]                         ` <mailman.8956.1410843332.1147.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 30+ messages in thread
From: Alex Kost @ 2014-09-16  4:55 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg (2014-09-16 02:45 +0400) wrote:

> Alex Kost <alezost@gmail.com> writes:
>
>> A comment to your hint.
>>
>> As you are using Gnus, you may just attach your elisp
>> file (or buffer) to make it be highlighted inline:
>> "C-c RET f" (or "C-c RET b") and choose
>> "application/emacs-lisp" type.
>
> I'm using Gnus - but I'm not the one reading the post.
>
> How will that make it look for people not using Gnus?

I don't know (and I don't care actually), but I think attachments should
be recognized by any client.

> I like to have my posts totally client-agnostic. But if
> it doesn't bloat the post with too much
> incomprehensible metadata for the non-Gnuser, I'll
> consider it - why not encourage people to switch to
> Gnus?
>
> OK - here is the attached Elisp:
>
> Wait - `C-c RET' is undefined, it says.
>
> Do you mean I (or any Gnuser reading such messages)
> should use your keystrokes in message-mode to get the
> highlight? But there, `C-c RET' is `gnus-article-mail'!
> What are the names of the commands?

Not in `gnus-article-mode'.

I mean those are the default keybindings for making attachments in
message-mode.  But they are available only if you use additional
functionality provided by Gnus, i.e. with:

  (setq mail-user-agent 'gnus-user-agent)

(Assuming that you use `compose-mail' command for making a new message).
Or you can just try "M-x gnus-msg-mail" instead.

Those commands are: `mml-attach-file' and `mml-attach-file'.

>> Another way is including org source blocks.
>
> You mean like this:
>
> #+BEGIN_SRC emacs-lisp
>   (defun org-xor (a b)
>      "Exclusive or."
>      (if a (not b) b))
> #+END_SRC
>
> Org manual example from:
>
> http://orgmode.org/manual/Working-With-Source-Code.html
>
> I have the same concerns for that method, but let's see
> how that works, as well.

This elisp block is properly highlighted for me.  If org blocks are not
highlighted for you, try:

(setq org-src-fontify-natively t)




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

* Re: how to add button to emacs that play a elisp code
       [not found]                         ` <mailman.8956.1410843332.1147.help-gnu-emacs@gnu.org>
@ 2014-09-16 22:27                           ` Emanuel Berg
  0 siblings, 0 replies; 30+ messages in thread
From: Emanuel Berg @ 2014-09-16 22:27 UTC (permalink / raw)
  To: help-gnu-emacs

Alex Kost <alezost@gmail.com> writes:

> Those commands are: `mml-attach-file' and
> `mml-attach-file'.

`mml-attach-file' I do have (but only one :) - it is
the one I use to attach stuff. I have that `C-a C-a',
only.

I see that with 'emacs -Q' it is indeed `C-c RET f' as
well so that must been something I configured, somehow
(?).

Using this method, I can find out that the other
function is `mml-attach-buffer'.

OK, I'll try those two now!

With `mml-attach-file': ...

With `mml-attach-buffer': ...

Neither worked:

    Couldn't send message via news: 441 Invalid Content
    type

How this will look in Gnus, I'll soon find out. But how
it will look in other clients (not to mention web
interfaces) I don't know - what I remember from Outlook
ten years ago was a small clip icon you had to click to
get the attachment. So I prefer inline to that.

Wait, that gave me an idea. Let's do the same thing
only inline:

(remove mml-attach-file + inline; same problem)

(removed mml-attach-buffer + inline; ditto)

So what I can see killing and yanking is still the
best!

Hypothesis: Maybe this stuff works for mail, but not
Usenet?

--
underground experts united


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

end of thread, other threads:[~2014-09-16 22:27 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-11  7:44 how to add button to emacs that play a elisp code Renato Pontefice
2014-09-11  8:08 ` Gian Uberto Lauri
2014-09-11  8:40   ` Gian Uberto Lauri
2014-09-11 12:17     ` Stefan Monnier
2014-09-11 12:22       ` Gian Uberto Lauri
2014-09-11 12:35         ` Stefan Monnier
2014-09-11 12:46           ` Gian Uberto Lauri
     [not found]         ` <mailman.8685.1410439222.1147.help-gnu-emacs@gnu.org>
2014-09-11 21:15           ` Emanuel Berg
2014-09-11 23:42             ` Pascal J. Bourguignon
2014-09-12  0:05               ` Emanuel Berg
2014-09-12  0:23                 ` Michael Heerdegen
     [not found]                 ` <mailman.8717.1410481417.1147.help-gnu-emacs@gnu.org>
2014-09-12  0:50                   ` Emanuel Berg
2014-09-12  1:19                     ` Michael Heerdegen
2014-09-12 14:52                       ` Drew Adams
     [not found]                     ` <mailman.8719.1410484774.1147.help-gnu-emacs@gnu.org>
2014-09-12  2:07                       ` Emanuel Berg
2014-09-12  7:44                         ` Renato Pontefice
2014-09-12 10:15                           ` Renato Pontefice
2014-09-12 19:33                             ` Emanuel Berg
2014-09-13 21:28                 ` Pascal J. Bourguignon
2014-09-14  2:30                   ` Rusi
2014-09-14  4:18                     ` Rusi
2014-09-14 18:16                     ` Emanuel Berg
2014-09-14 18:11                   ` Emanuel Berg
2014-09-15  5:48                     ` Alex Kost
     [not found]                     ` <mailman.8874.1410760111.1147.help-gnu-emacs@gnu.org>
2014-09-15 22:45                       ` Emanuel Berg
2014-09-16  4:55                         ` Alex Kost
     [not found]                         ` <mailman.8956.1410843332.1147.help-gnu-emacs@gnu.org>
2014-09-16 22:27                           ` Emanuel Berg
     [not found]   ` <mailman.8671.1410424828.1147.help-gnu-emacs@gnu.org>
2014-09-11 21:06     ` Emanuel Berg
     [not found] ` <mailman.8670.1410422963.1147.help-gnu-emacs@gnu.org>
2014-09-11  8:24   ` Renato Pontefice
2014-09-11 16:00 ` Pascal J. Bourguignon

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).