Visualizzazione post con etichetta lisp. Mostra tutti i post
Visualizzazione post con etichetta lisp. Mostra tutti i post

domenica 7 agosto 2016

Emacs, elisp e suggest.el

L'ecosistema di Emacs è veramente molto esteso e denso, ed è facile perdersi al suo interno.
Oggi ho scoperto un pacchetto denominato "suggest"  il cui scopo è tanto semplice quando sbalorditivo: dato un input e un output questo fornisce una lista di potenziali funzioni elisp che possono soddisfare la condizione.

mercoledì 10 ottobre 2012

Emacs: creating PHP getters and setters easily

Following the initial work on the GNU Emacs and PHP class generator,  I developed a lisp function to create the getter/setter methods, and since I was developing, I thought it would be much more powerful to have the definition of the whole property. The function php-prop does all the stuff: it prompts the user for a property name (that is the name of the internal variable) and for an optional comment to place on the property. After that the function places a private property at the cursor current point, and then scans the current class for a getter and a setter for the same property. If one or both of the previous methods are not found, the function generates the code for them at the very end of the class. The function also places comments in doxygen format using also the current username and e-mail (that have to be set in the Emacs configuration). 
Loading the function allows you to insert a PHP property just hitting M-x php-prop.

domenica 7 ottobre 2012

Emacs PHP class template generator

I use GNU Emacs as my default for a lot of stuff, including developing in PHP. Unluckily the great php-mode does not include a lot of common stuff to handle with OOP PHP programming. So I decided to develop a PHP class template generator, a lisp function that prompts for the class name (that will be capitalized and will be stored in a file with the same name) and for an optional comment, and then generates a class skeleton in a new buffer, saving the result to a file. Actually there are two versions of the function, the base one php-class executes the other php-class-in-path with the current working directory as path. The path is used to let Emacs know where to save the new buffer. In both cases, if a file with that name is already existent, the function aborts.
Therefore, calling M-x php-class and inserting a class name will make a new buffer appearing, with the class skeleton and a new file with such class will be saved.