Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 135
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 135
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 187
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 188
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 189
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 194
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 195
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 196
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 197
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 241
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 264
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 269
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 275
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 285
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 286
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 296
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 297
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 298
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 308
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 309
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 310
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 311
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 321
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 322
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 323
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 324
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 325
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 497
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 527
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 540
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 587
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 626
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 668
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 668
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 670
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 673
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 682
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 688
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 693
Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php on line 699
Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 410
Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 410
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 272
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 274
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 274
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 274
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/public/lib.urlhandlers.php on line 110
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/public/lib.urlhandlers.php on line 130
Warning: Cannot modify header information - headers already sent by (output started at /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.json.php:309) in /home/didierve/didierverna.net/blog/inc/libs/clearbricks/common/lib.http.php on line 295 Didier Verna's Scientific Blog - Tag - hackDidier Verna's scientific blog: Lisp, Emacs, LaTeX and random stuff.2024-01-31T17:45:28+00:00Didier Vernaurn:md5:a22c53786aff986a2da4c770c233a8f9DotclearTranslucent XEmacs coming in hot !!urn:md5:9bcb3866a6ebd58f796c9ee5b03b250dThursday, February 25 2010Thursday, February 25 2010xemacs(X)EmacsEmacs Lisphacksoftware I'm uploading a set of changes to the XEmacs 21.5 Mercurial repository right now. These changes implement a new face property named "background-placement" which makes an XEmacs frame "slide" over a face's background pixmap when the property is set to 'absolute.<br /><br />If you do this on the default face, then you can achieve some sort of pseudo-translucency, for example by using the same (or a darkened version of) the root window's background pixmap.<br /><br />Here are a couple of screenshots that illustrate this.<br /><br /><a target="_blank" href="https://www.didierverna.net/sciblog/public/txunix.png"><img title="Translucent XEmacs on Unix, Jan 2011" alt="" src="https://www.didierverna.net/sciblog/public/.txunix_s.jpg" /></a> <a target="_blank" href="https://www.didierverna.net/sciblog/public/txosx.png"><img title="Translucent XEmacs on MacOS X, Jan 2011" alt="" src="https://www.didierverna.net/sciblog/public/.txosx_s.jpg" /></a><br /><br /><br />https://www.didierverna.net/blog/index.php?post/2010/02/25/Translucent-XEmacs-coming-in-hot-%21%21#comment-formhttps://www.didierverna.net/blog/index.php?feed/navlang:en/atom/comments/24CCL Objective C bridge code indentationurn:md5:dadc3fa8c26c6acf7204374ddaf89533Tuesday, July 1 2008Tuesday, July 1 2008Didier VernaLispCCLEmacs LisphackObjective Csoftware A whole bunch of CCL Cocoa coding involves calls to ObjC methods. For instance, the following ObjC code:<pre>[cell drawWithFrame: frame inView: view];</pre> will translate into this in CLL: <pre>(#/drawWithFrame:inView: cell frame view)</pre>. Indeed, Objective C is designed around the record-based model (methods belong to classes), so the cell object receives the drawWithFrame:inView: message via the funny bracket syntax. On the other hand, the Lisp translation involves a generic function call with the usual funcall syntax. The dispatch occurs on the first argument (the cell), and the rest is actual arguments to the message.<br /><br />This layout is obviously not optimal for readability. One could define a bracket reader-macro to simulate ObjC's message passing syntax in Lisp, but I prefer to stick to the "Lisp Way". The first argument should still be considered "special" though.<br /><br />For readability (especially when the method name is long), I like to put the arguments to the message (not the receiver!) on subsequent lines. However, XEmacs's <code>cl-indent-function</code> will indent this as an ordinary function call, like this:<pre>(#/drawWithFrame:inView: cell<br /> frame view</pre> which is awfull. What I want is the following indentation: <pre>(#/drawWithFrame:inView: cell<br /> frame view</pre> This kind of indentation is normally achieved by putting a <code>common-lisp-indent-function</code> property of 1 on the function symbol. However, you don't want to do that on all possible ObjC message by hand (and you don't know them all in advance anyway). The following advice on <code>common-lisp-indent-function</code> (from the <code>cl-indent</code> package does the trick. It dynamically puts the property on each relevant symbol every time it is subject to indentation. A bit brute force, but it works smoothly.<pre>(defadvice common-lisp-indent-function (before ccl-objc-bridge activate)<br /> "Improve indentation scheme of the CCL Objective-C bridge.<br />Currently, this does the following:<br /><br />- All (#/doThis:withThat: ...) forms are indented as per a<br />lisp-indent-function property of 1. This effectively treats the first argument<br />(an object or a class) as special. The indentation you get is:<br /><br /> (#/function arg1 instead of: (#/function arg1<br /> arg2 ...) arg2 ...)"<br /> (let ((containing-form-start (elt state 1)))<br /> (save-excursion<br /> (goto-char containing-form-start)<br /> (forward-char 1)<br /> (cond ((looking-at "#/\\(\\w\\|:\\)*:")<br /> ;; We're looking at a (#/doThis:withThat: ...) form. In its holy<br /> ;; brokenness, common-lisp-indent-function with the help of<br /> ;; parse-partial-sexp will consider that the function name in<br /> ;; this form is "/functioncall:". Our trick here is to<br /> ;; dynamically put a lisp-indent-function property of 1 on this<br /> ;; symbol, so that the subsequent (original) indenting function<br /> ;; will handle it.<br /> (let* ((beg (progn (forward-char 1) (point)))<br /> (sym (progn<br /> (forward-sexp 1)<br /> (intern (downcase (buffer-substring beg<br /> (point)))))))<br /> (put sym 'common-lisp-indent-function 1)))))))</pre><br />One last thing and I'll be happy: I want to indent CCL's slet and slet* constructs just as let:<pre>(put 'slet 'common-lisp-indent-function <br /> '((&whole 4 &rest (&whole 1 1 2)) &body))<br />(put 'slet* 'common-lisp-indent-function<br /> '((&whole 4 &rest (&whole 1 1 2)) &body))</pre><br />Et voilĂ !https://www.didierverna.net/blog/index.php?post/2008/07/01/CCL-Objective-C-bridge-code-indentation#comment-formhttps://www.didierverna.net/blog/index.php?feed/navlang:en/atom/comments/48Beamer blocks and the Listings packageurn:md5:209e8ca9299e0a6c351ff87e2850d8b0Wednesday, June 4 2008Wednesday, June 4 2008Didier VernaLaTeXBeamerhacklstlistingsoftware For many of my lectures, I use the Listings package for typesetting code excerpts, and include them in Beamer blocks. Providing nice shortcuts for doing that is not trivial if you want to preserve control over Listings options, and add a new one for the block's title. Here is a way to nicely wrap a call to <code>\lstinputlisting</code> inside a Beamer block.<br /><br />First, let's use the <code>xkeyval</code> package to create a "title" option:<br /><pre>\define@cmdkey[dvl]{lst}[@dvl@lst@]{title}{}</pre><br />Next, a low-level listing input command. This macro takes 4 arguments: an overlay specification, a title for the block, a list of options passed to Listings, and a file name for input:<br /><pre>%% \dvlinputlisting{overlay}{title}{lstoption=,...}{file}<br />\newcommand\dvlinputlisting[4]{%<br /> \begin{block}#1{#2}<br /> %% #### WARNING: I need this hack because keyval-style options<br /> %% mess up the parsing.<br /> \expandafter\lstinputlisting\expandafter[#3]{#4}<br /> \end{block}}</pre><br />And now, you can define all sorts of specialized versions for different languages. For example, here is one for Common Lisp code. The block title is "Lisp" by default, and a "lisp" extension is automatically added to the file name:<br /><pre>%% Language-specific shortcuts:<br />%% The title option is used for the beamer block's title.<br />%% All other options are passed to listings.<br />%% \XXXinputlisting<overlay>[title=,lstoption=,...]{file}<br />\newcommand<>\clinputlisting[2][]{%<br /> \def\@dvl@lst@title{Lisp}%<br /> \setkeys*[dvl]{lst}{#1}%<br /> \edef\@dvl@lst@options{language=lisp,\XKV@rm}%<br /> \dvlinputlisting{#3}{\@dvl@lst@title}{\@dvl@lst@options}{#2.lisp}}</pre><br />Which you could call like this:<br /><pre>\clinputlisting<2->[title={Example 1}, gobble=2]{ex1}</pre><br />As you can see, "title" is an option for the Beamer block, and all the others are dispatched to Listings. Cool.<br /><br /><br />Now, things are getting more complicated when you want nice shortcuts for <em>inline environments</em>, because nesting Beamer blocks with listings doesn't work. Fortunately, I figured out a trick based on the Verbatim package to simulate that. The idea is to store the contents of the listing environment in a temporary file, and use <code>\lstinputlisting</code> as before to include it. Clever right ?<br />:-)<br />Here is a generic environment for doing that. In the opening, we read the environment's contents and store it in the file <code>\jobname.dvl</code>. In the ending, we call our previous macro <code>\dvlinputlisting</code> on that file (actually, on a dynamically created argument list called <code>\@dvl@args</code>:<br /><pre>\usepackage{verbatim}<br />\newwrite\lstvrb@out<br />\def\@dvllisting{%<br /> \begingroup<br /> \@bsphack<br /> \immediate\openout\lstvrb@out\jobname.dvl<br /> \let\do\@makeother\dospecials\catcode`\^^M\active<br /> \def\verbatim@processline{%<br /> \immediate\write\lstvrb@out{\the\verbatim@line}}%<br /> \verbatim@start}<br />\def\@enddvllisting{%<br /> \immediate\closeout\lstvrb@out<br /> \@esphack<br /> \endgroup<br /> \expandafter\dvlinputlisting\@dvl@args}</pre><br />And now, we can define all sorts of specialized versions for every language we're insterested in. Again, here is one for Common Lisp.<br /><pre>\newenvironment<>{cllisting}[1][]{%<br /> \def\@dvl@lst@title{Lisp}%<br /> \setkeys*[dvl]{lst}{#1}%<br /> \edef\@dvl@lst@options{language=lisp,\XKV@rm}%<br /> \xdef\@dvl@args{{#2}{\@dvl@lst@title}{\@dvl@lst@options}{%<br /> \jobname.dvl}}<br /> \@dvllisting}{%<br /> \@enddvllisting}</pre><br />Which you can use like this:<br /><pre>\begin{cllinsting}<2->[title={Example 1},gobble=2]<br /> (defun foo (x) (* 2 x))<br />\end{cllisting}</pre><br />Don't forget that frames containing code excerpts like this are <em>fragile</em>!https://www.didierverna.net/blog/index.php?post/2008/06/04/Beamer-blocks-and-the-Listings-package#comment-formhttps://www.didierverna.net/blog/index.php?feed/navlang:en/atom/comments/49