help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cperl-indent-for-comment


From: LanX
Subject: Re: cperl-indent-for-comment
Date: Thu, 6 May 2010 14:39:15 -0700 (PDT)
User-agent: G2/1.0

Hi

> Why not do it more agressively, and just avoid it after $ ?

hmm ... technically I was worrying about #-delimiters like in
regexes ... but testing the face should already be sufficient.

I th this DWIM behavior should be restricted to the same end-of-line
scenarios like auto-newline.

If I need it explicitly from within the code I can use C-#.

But indeed thats a matter of taste and could be made customizable ...

> Keep in mind that one needs to force update of syntaxification before
> checking text-properties.
>
>         (cperl-update-syntaxification (point) (point))

Good point 8)

-------------------------------------- Version 0.02
(defun my-indent-for-comment (arg)
  "dwim indent-for-comment"
  (interactive "p")
  (cperl-update-syntaxification (point) (point))
  (if (and (memq (preceding-char)  '( ?\; ?{ ?\( ?\[ ) )
           (not   (get-text-property (point) 'face)))
      (indent-for-comment)
    (insert "#"))
  )

(local-set-key (kbd "#") 'my-indent-for-comment)
----------------------------------------

TODO:
- checking for after code (whitespace till end of line)
- adding this case to cperl-electric-backspace
- handling the case of auto-newline.


> Not in my version.

your still running emacs 19 right?

For completeness:

putting the cursor right after the doublequote and pressing M-;
results in this
------------------------------------
$a="                            # #
------------------------------------

every new try appends a new " #"

I started "emacs22 -q" and emacs23 and tested it with cperl "5.23 and
"6.2". (perl-mode is OK)

But this is not a really important bug...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]