From: Mario S. Mommer on

Jorge Gajon <gajon(a)gajon.org> writes:
> What I'm actually afraid is getting lured into "this new plugin", and
> then this "other cool plugin", oh! and there's this other one!.
[...]
> Dangerous stuff.

Look, it is fun, it makes you productive, and it doesn't hurt. It makes
your head spin, but not in a way you'll regret. Where's the problem? :-)
From: Tim Bradshaw on
On 2010-04-24 22:42:29 +0100, Mario S. Mommer said:

> Look, it is fun, it makes you productive, and it doesn't hurt.

It may be fun, but I can speak from some experience when I say that the
endless cycle of "let's just find another extension to play with" is
*not* productive. Indeed, if it wasn't for Emacs I'm reasonably
certain I would be in charge of the world by now.

From: Scott L. Burson on
On Apr 22, 8:32 am, Raffael Cavallaro
<raffaelcavall...(a)pas.espam.s.il.vous.plait.mac.com> wrote:
>
> The language needs to be sold macros-first if it is to have any chance
> of convincing newcomers that fully parenthesized syntax is a good
> thing.

Yes! An excellent point.

-- Scott
From: Jorge Gajon on
On 2010-04-24, Pascal J. Bourguignon <pjb(a)informatimago.com> wrote:
> Jorge Gajon <gajon(a)gajon.org> writes:
>
>> On 2010-04-24, Pascal J. Bourguignon <pjb(a)informatimago.com> wrote:
>>> Jorge Gajon <gajon(a)gajon.org> writes:
>>>
>>>> On 2010-04-22, Peter Keller <psilord(a)merlin.cs.wisc.edu> wrote:
>>>>> I am a staunch vim user, to say the least. However, after patches I
>>>>> was giving back to various lisp projects were rejected with the reason
>>>>> "format it in SLIME or else". I bit the bullet and simply learned emacs
>>>>> for my Lisp IDE. I'm happy I did this.
>>>>>
>>>>
>>>> Hi Peter,
>>>>
>>>> I'm an avid Vim user as well, and I've been using "Limp" with a few
>>>> modifications�. I've been playing a little bit with Emacs and SLIME, and
>>>> I can clearly see that the Emacs platform is much more powerful and that
>>>> there's nothing like SLIME available to VIM.
>>>>
>>>> However, I've been hesitant to completely immerse myself into Emacs
>>>> mainly because I'm afraid that I will spend endless hours learning and
>>>> customizing it, without gaining a significant advantage over Vim.
>>>
>>> You could. But you wouldn't have to, to benefit from emacs lisp.
>>> Really, I usually don't spend any time on emacs customization, in the
>>> course of a project. On the other hand, I may spend a few minutes to
>>> write project specific emacs lisp functions, to help editing or
>>> generating project specific stuff.
>>>
>>
>> Pascal, when you say "...help editing or generating project specific
>> stuff", do you mean text templates that are expanded in place and you
>> fill the blanks, or do you mean something similar to keyboard macros to
>> avoid repetition, or a combination of them.
>
> The former. I don't use keyboard macros, since I'm totally at ease with
> emacs lisp programming, I do what users would do with keyboard macros
> writing emacs functions.
>
>
> Here are some typical example.
>
> - The first would be a command to set different faces to different log
> level in an application specific log file (which application issued a
> lot of logs in debugging mode, so that it was really important to be
> able to distinguish them by color to make sense of them).
>
> (defun xxxxxx-log-fontify-buffer ()
> (interactive)
> (remove-all-properties)
> (dolines (lstart lend)
> (goto-char lstart)
> (when (looking-at "\\(DEBUG\\|INFO\\|NOTICE\\|WARNING\\|ERROR\\) ")
> (let* ((level (match-string 1))
> (face (cond
> ((string= level "DEBUG") 'xxxxxx-message-level-debug)
> ((string= level "INFO") 'xxxxxx-message-level-info)
> ((string= level "NOTICE") 'xxxxxx-message-level-notice)
> ((string= level "WARNING") 'xxxxxx-message-level-warning)
> ((string= level "ERROR") 'xxxxxx-message-level-error))))
> ;; (message "%S %S %S %S" level face lstart lend)
> (when face (facemenu-set-face face lstart lend))))))
>
>
> (This could have been done with normal font-lock keywords, but it was
> too slow given the size of the log files).
>
> Also there's a function that set as an emacs attribute attached to
> each log line, a log object, identifying the log message in the
> sources (since there was no identification of the log message other
> than its pattern, not to affraid the users). So that I could easily
> jump from the log line to the corresponding source line.
>
>
> - a function that would take a C++ message sending ("member function
> call"), and transform it into sending a message to a scheduler object
> with a boost::bind wrapping the original message send. (Transforming
> the original message send into an asynchronous one). Of course, such
> a feature would be implemented at the programming language level (ie.
> with lisp macros), instead of inlining it in the source, but we can
> use emacs lisp function to "macro expand" the target language.
>
>
> - a funnier set of emacs commands were used to switch between two
> representations of a function definition in a language where there was
> no function definition available. Only eval(string) was availble, so
> that I defined a syntax to define a function, and the function
> parameters were passed thru global variables like in BASIC, and the
> function body was stored into a string named by the function. The
> commands switched between the two forms:
>
> function f(input a,inout b,output c){
> b=b+1;
> c=a*2;
> }
>
> <->
>
> a=null; // input of f
> b=null; // inout of f
> c=null; // output of f
> f="b=b+1;c=a*2";
>
> to try to recover some mental sanity...
>
> I didn't write the switch for function calls, (ie between f(i,j,k) and
> a=i;b=j;eval(f);k=c;) but it could have been done with some more
> syntactic analysis of this dumb language.
>
>
> - finally, one can also quite easily interface with underlying programs,
> such as debuggers, writing emacs commands to drive the debugger or
> other programs with a single key. For example, I have:
>
>
> (defun clisp-debug-keys ()
> "Binds locally some keys to send clisp debugger commands to the inferior-lisp
> <f5> step into
> <f6> next
> <f7> step over
> <f8> continue
> "
> (interactive)
> (macrolet ((cmd (string)
> `(lambda ()
> (interactive)
> (comint-send-string (inferior-lisp-proc)
> ,(format "%s\n" string)))))
> (local-set-key (kbd "<f5>") (cmd ":s"))
> (local-set-key (kbd "<f6>") (cmd ":n"))
> (local-set-key (kbd "<f7>") (cmd ":o"))
> (local-set-key (kbd "<f8>") (cmd ":c"))))
>
> (defun sbcl-debug-keys ()
> "Binds locally some keys to send clisp debugger commands to the inferior-lisp
> <f5> step into
> <f6> next
> <f7> step over
> <f8> continue
> "
> (interactive)
> (macrolet ((cmd (string)
> `(lambda ()
> (interactive)
> (comint-send-string (inferior-lisp-proc)
> ,(format "%s\n" string)))))
> (local-set-key (kbd "<f5>") (cmd "step"))
> (local-set-key (kbd "<f6>") (cmd "next"))
> (local-set-key (kbd "<f7>") (cmd "over"))
> (local-set-key (kbd "<f8>") (cmd "out"))))
>
> (defun allegro-debug-keys ()
> "Binds locally some keys to send allegro debugger commands to the inferior-lisp
> <f5> step into
> <f7> step over
> <f8> continue
> "
> (interactive)
> (macrolet ((cmd (string)
> `(lambda ()
> (interactive)
> (comint-send-string (inferior-lisp-proc)
> ,(format "%s\n" string)))))
> (local-set-key (kbd "<f5>") (cmd ":scont 1"))
> ;; (local-set-key (kbd "<f6>") (cmd ))
> (local-set-key (kbd "<f7>") (cmd ":sover"))
> (local-set-key (kbd "<f8>") (cmd ":continue"))))
>
>
> In this specific case of Common Lisp, of course SLIME does it for you
> already. When I started programming in Lisp, SLIME didn't exist yet.
>
>
>> Or (more exciting), you mean something like CL macros where you call
>> it with some arguments and depending on the arguments it will 'expand'
>> into different source code.
>
> Also this. For example, you may find in my sources in inferior
> programming languages, emacs lisp code in comments, that will generate
> the following inferior language code. Typically for repeatitive stuff.
> For example:
>
> /*
> (insert-fields '(visible color width height))
> */
>
> private $visible=null;
> public function setVisible($aValue){ $this->visible=$aValue; return($this); }
> public function getVisible(){ return($this->visible); }
> private $color=null;
> public function setColor($aValue){ $this->color=$aValue; return($this); }
> public function getColor(){ return($this->color); }
> private $width=null;
> public function setWidth($aValue){ $this->width=$aValue; return($this); }
> public function getWidth(){ return($this->width); }
> private $height=null;
> public function setHeight($aValue){ $this->height=$aValue; return($this); }
> public function getHeight(){ return($this->height); }
>
>
> But I may also use the same technique to generate more complex code, for
> example optimized decision trees (embedded ifs).
>
>
> Notice there's an emacs lisp pre-processor:
>
> http://www.xcf.berkeley.edu/~ali/elpp/cgen.el
> http://www.xcf.berkeley.edu/~ali/elpp/elpp.el
> http://www.xcf.berkeley.edu/~ali/elpp/elppc.el
>
> Basically it allows you to insert elisp in your C code and to
> autogenerate C code from elisp s-expressions. (I guess you could apply
> it to other programming languages too).
>
> But then your sources wouldn't be C sources, but C+emacs lisp, so it
> would be harder to commit them in your employer's repositories.
> Commiting comments with emacs lisp code is already hard enough...
>
>

Thank you Pascal, for these detailed examples. The first two examples
were specially interesting to me.

I've superficially used Emacs before, I know the basic commands, but I
will start learning it deeper now. I'm more convinced now that there it
can be worth the effort.

Best regards.

From: Jorge Gajon on
On 2010-04-24, Mario S. Mommer <m_mommer(a)yahoo.com> wrote:
>
> Jorge Gajon <gajon(a)gajon.org> writes:
>> What I'm actually afraid is getting lured into "this new plugin", and
>> then this "other cool plugin", oh! and there's this other one!.
> [...]
>> Dangerous stuff.
>
> Look, it is fun, it makes you productive, and it doesn't hurt. It makes
> your head spin, but not in a way you'll regret. Where's the problem? :-)

I don't know. Without a proper context it would seem like you are trying
to convince me to smoke a joint :)