[Openmcl-devel] Alternative parens

Ron Garret ron at flownet.com
Fri Apr 26 09:53:55 PDT 2013

On my system, C-M doesn't do anything:

? (hi::get-command #k"C-M" :mode "editor")

But I'm a mouser, not an emacser, so that's not really what I care about.  What I want is matching-paren highlighting and editor-eval-sexpr to work.  Double-clicking on a close-bracket to highlight a sexpr would be nice too.

Actually, what I *really* want is not to use brackets as parens (though that would be nice too) but for «balanced quotes» to work.  I have reader macros for balanced quotes that do the Right Thing.  I use them to embed code written in other languages, mainly Javascript.  This way, if there is a double quote in the embedded string I don't have to escape it.  The problem is that if there's a semicolon in the embedded string, Hemlock treats it as a Lisp comment because it doesn't know it's inside a string.  If there's an unbalanced paren after the semicolon, that throws off paren matching, e.g.:

(defvar *js-template* «

var s = "foo";  // Using balanced quotes means you don't need to escape double quotes in the embedded string
function foo() {
  for (var i=1; i<10; i++) ...;   // Hemlock misinterprets on this line and screws up syntax highlighting


Here's the balanced quote reader code in case you want to play around with this:

(defun make-string-reader (c1 c2)
  (lambda (stream c)
    (declare (ignore c))
    (with-output-to-string (s)
      (loop for c = (read-char stream)
        with cnt = 1
        if (eql c c1) do (incf cnt)
        else if (eql c c2) do (decf cnt)
        until (and (eql c c2) (eql cnt 0))
        do (princ c s)))))

(set-macro-character #\« (make-string-reader #\« #\»))


On Apr 26, 2013, at 6:55 AM, Glen Foy wrote:

> This works once you define the character attributes:
> With point at the start the form shown below, C-M f will move point to the end of the form, and then C-M b will move you back to the start:
> [foo [bar]]                                                                                               [foo [bar]]
> ^                                                                                                                               ^
> If the attributes are not defined, C-M f will move you to the end of 'foo':
>                                                                                                                  [foo [bar]]
>                                                                                                                        ^
> The nested form also seems to work appropriately when the attributes are defined. The "Forward Form" command calls the basic hemlock function, hemlock::form-offset.
> What functionality are you not getting?
> -- Glen
> On Apr 25, 2013, at 8:44 PM, Ron Garret <ron at flownet.com> wrote:
>> Looking at the code in
>> cocoa-ide/hemlock/src/defsyn.lisp
>> it would appear that if one did, e.g.:
>> (setf (hi::character-attribute :lisp-syntax #\[) :open-paren)
>> (setf (hi::character-attribute :lisp-syntax #\]) :close-paren)
>> that the editor should then treat square-bracketed expressions the same as paren-bracketed ones.  But it doesn't seem to work.  What is the right way to get Hemlock to recognize other kinds of balanced delimiters?
>> Thanks,
>> rg
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list