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

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

Re: CPerl mode v5.0


From: Ilya Zakharevich
Subject: Re: CPerl mode v5.0
Date: Mon, 17 Feb 2003 07:56:52 +0000 (UTC)

[A complimentary Cc of this posting was sent to
Daniel Pfeiffer 
<occitan@esperanto.org>], who wrote in article 
<20030211222108.11234512.occitan@esperanto.org>:
> Here is a little snippet of (wrong!) Perl code, which shows what is needed
> to catch each of the font-lock errors:
> 
> \$"asd"
> \$'asd'
> \$`asd`

Fixed by one-byte-long edit to cperl-mode.el.

> $opt_s!asd!bsd!
> $opt::s!asd!bsd!

Each requires 3-byte-long edits to fix (at least kinda-fix; a full fix
which distinguishes : from :: takes 2 lines ;-).

Shortly: stupid me!  It turned out that all the infrastructure (the
code) was already there, all I needed to change were a couple of
tables (i.e., the data).

> $opt{s}asd}bsd}
> (s => ...)=bsd=

These (and a couple more I discovered) take around 40 LOC to handle.

CPerl-mode v5.0 should be available for download in a couple of hours
(forwarding setup should propagate first) from the temporary address

  www.ilyaz.org/software2/emacs/

v4.35 is provided too as a basis to merge3 other versions.  All the
bugs I could reproduce are fixed.  A couple of limitations remain (see
TODO).

I recommend looking for bugs ASAP; for minor matters I'm going to go
into append-to-TODO maintainace mode quite soon.

Yours,
Ilya

======================================================= CHANGES

;;;; After 4.32:
;;;  Syncronized with v1.40+recent-patch from Emacs 21.3.
;;;  Mostly docstring and formatting changes, and:

;;;  (`cperl-noscan-files-regexp'): Do not scan CVS subdirs
;;;  (`cperl-problems'):            Note that newer XEmacsen may syntaxify too
;;;  (`imenu-example--create-perl-index'):
;;;                     Renamed to `cperl-imenu--create-perl-index'
;;;  (`cperl-mode'):            Replace `make-variable-buffer-local' by 
`make-local-variable'
;;;  (`cperl-setup-tmp-buf'):   Likewise
;;;  (`cperl-fix-line-spacing'): Fix a misprint of "t" for "\t"
;;;  (`cperl-next-bad-style'):  Fix misprints in character literals

;;;; After 4.33:
;;;  (`cperl-font-lock-keywords'): +etc: Aliased to perl-font-lock-keywords.

;;;; After 4.34:
;;;  Further updates of whitespace and spelling w.r.t. RMS version.
;;;  (`cperl-font-lock-keywords'): +etc: Avoid warnings when aliasing.
;;;  (`cperl-mode'):            Use `normal-auto-fill-function' if present.
;;;  (`cperl-use-major-mode'):  New variable
;;;  (`cperl-can-font-lock'):   New variable; replaces `window-system'
;;;  (`cperl-tags-hier-init'):  use `display-popup-menus-p' (if present)
;;;                             to choose `x-popup-menu' vs `tmm-prompt'

;;;; 4.35 has the following differences from version 1.40+ of RMS Emacs:

;;; New variables `cperl-use-major-mode', `cperl-can-font-lock';
;;; `cperl-use-major-mode' is (effectively) 'cperl-mode in RMS.
;;; `cperl-under-as-char'  is nil in RMS.
;;; Minor differences in docstrings, and `cperl-non-problems'.
;;; Backward compatibility addressed: (`); (function (lambda ...)); font-lock;
;;; (:italic t bold t) vs (:slant italic :weight bold) in faces;
;;; `normal-auto-fill-function'.
;;; RMS version has wrong logic in `cperl-calculate-indent': $a = { } is
;;; wrongly indented if the closing brace is on a separate line.
;;; Different choice of ordering if's for is-x-REx and (eq (char-after b) ?\#)
;;; in `cperl-find-pods-heres'. [Cosmetic]

;;;; After 4.35:
;;;  (`cperl-find-pods-heres'): If no end of HERE-doc found, mark to the end
;;;                             of buffer.  This enables recognition of end
;;;                             of HERE-doc "as one types".
;;;                             Require "\n" after trailing tag of HERE-doc.
;;;                             \( made non-quoting outside of string/comment
;;;                             (gdj-contributed).
;;;                             Likewise for \$.
;;;                             Remove `here-doc-group' text property at start
;;;                             (makes this property reliable).
;;;                             Text property `first-format-line' ==> t.
;;;                             Do not recognize $opt_s and $opt::s as s///.
;;;  (`cperl-perldoc'):         Use case-sensitive search (contributed).
;;;  (`cperl-fix-line-spacing'): Allow "_" in $vars of foreach etc. when
;;;                             underscore isn't a word char (gdj-contributed).
;;;  (`defun-prompt-regexp'):   Allow prototypes.
;;;  (`cperl-vc-header-alist'): Extract numeric version from the Id.
;;;  Toplevel:                  Put toggle-autohelp into the mode menu.
;;;                             Better docs for toggle/set/unset autohelp.
;;;  (`cperl-electric-backspace-untabify'): New customization variable
;;;  (`cperl-after-expr-p'):    Works after here-docs, formats, and PODs too
;;;                             (affects many electric constructs).
;;;  (`cperl-calculate-indent'): Takes into account `first-format-line' ==>
;;;                             works after format.
;;;  (`cperl-short-docs'):      Make it work with ... too.
;;;                             "array context" ==> "list context"
;;;  (`cperl-electric-keyword'): make $if (etc: "$@%&*") non-electric
;;;                             '(' after keyword would insert a doubled paren
;;;  (`cperl-electric-paren'):  documented affected by `cperl-electric-parens'
;;;  (`cperl-electric-rparen'): Likewise
;;;  (`cperl-build-manpage'):   New function by Nick Roberts
;;;  (`cperl-perldoc'):         Make it work in XEmacs too

;;;; After 4.36:
;;;  (`cperl-find-pods-heres'): Recognize s => 1 and {s} (as a key or varname),
;;;                             { s:: } and { s::bar::baz } as varnames.
;;;  (`cperl-after-expr-p'):    Updates syntaxification before checks
;;;  (`cperl-calculate-indent'): Likewise
;;;                             Fix wrong indent of blocks starting with POD
;;;  (`cperl-after-block-p'):   Optional argument for checking for a pre-block
;;;                             Recognize `continue' blocks too.
;;;  (`cperl-electric-brace'):  use `cperl-after-block-p' for detection;
;;;                             Now works for else/continue/sub blocks
;;;  (`cperl-short-docs'):      Minor edits; make messages fit 80-column screen

======================================================= TODO etc

* Fontification of arrays and hashes is overeager.

* Make cperl-fix-line-spacing work with non-CPerl whitespace styles too

* Start emacs with '-q' and probably --no-site-file (see below)
  Load this into a buffer:
  -------------------- snip, snip -----------------------
  {
    #  'next LINE;'
    #  'next PAT;
  }
  -------------------- snip, snip -----------------------

  Switch cperl-mode on
  Narrow the buffer down to the region starting with the first comment-line
  and ending with the last.
  (It now should look like this:
    #  'next LINE;'
    #  'next PAT;
  )

  Position the cursor on the beginning of the first comment-line
  Press <TAB>
  => emacs freezes; it has to be killed

* Make C-Enter do reasonable thing if after $var in 
  for $var () {}

* Make electric braces configurable depending on POD, comment, string

* my (  $var1, # comment
        $var2);
  mishighlighted.

* The generated TAGS contain package::subname, but not just subname

* Indent //x-Rexen according to REx syntax;

* # Now do the loop.  This has god a -2 comment-anti-indent.
    foreach ( @thing ) {
        print $_ . "\n";
    }

  I like the comment text to line up with the code (AS ABOVE), rather than

*
                Hello,
                Recently, a friend asked me to write him a pod only spell
checker.  I was happy to oblige; and did so.  He seemed to like it and
asked me to submit it.  If you would enjoy it, I appended it below.
                                         Have a nice evening,
                                 -Trey Belew


(defun pod-spell ()
  "A function to only check pod documentation"
  (interactive "*")
  (save-excursion
        (let ((element 0)
                    (my-list (make-pod-list)))
            (while (< element (length my-list))
                  (setq the-first (car (nth element my-list)))
                  (setq the-second (cadr (nth element my-list)))
                  (ispell-region (car (nth element my-list)) (cadr (nth element 
my-list)))
                  (setq element (1+ element))))))

(defun make-pod-list ()
  "A function to make a list of syntactic elements which are pod/here 
documentation"
  (interactive)
  (goto-char (point-min))
  (let (
                (current 0)
                (pod-list '())
                (last-state nil)
                (done nil)
                (line 0)
                (pod-start 0))
        (while (not done)
            (setq the-state (get-text-property current 'in-pod))
                  (cond
                      ((and (eq last-state nil) (eq the-state t))   ;; a new 
pod is starting
                           (setq last-state the-state)
                           (setq pod-start current))
                             ((and (eq last-state t) (eq the-state nil))   ;; 
the end of a pod
                                  (setq last-state the-state)
                                  (setq pod-list (cons (list pod-start current) 
pod-list)))
                                    ((eq current (point-max))
                                         (setq done t)))
                    (setq line (1+ line))
                          (goto-line line)
                            (setq current (point)))  ;; end of the while loop.
        (reverse pod-list)))        ;; I reversed it just to make it prettier


* Here's what I use to get xemacs to correctly parse perl errors. I'm
  self-taught in elisp so I make no claims to this being pretty or
  correct, just functional for me. - Von


  ;; <error> at <file> line <num>
  (setq perl-compilation-regexp-alist
        '(("[^\n]* at \\([^ ]+\\) line \\([0-9]+\\)" 1 2)))

  ;; XXX should make value local...
  (cond ((boundp 'compilation-error-regexp-alist-alist) ;; xemacs 20.x
         (setq compilation-error-regexp-alist-alist
               (cons (cons 'perl perl-compilation-regexp-alist)
                            compilation-error-regexp-alist-alist))
         (compilation-build-compilation-error-regexp-alist))

        ((boundp 'compilation-error-regexp-alist) ;; xmeacs 19.x
         (setq compilation-error-regexp-alist
               (cons perl-compilation-regexp-alist
                     compilation-error-regexp-alist))
         )
        )


* Problem:
    if SPACE
  at the beginning of the line.  If this indents, SPACE is not removed
  with the electric expansion.                  CAN'T REPRODUCE

* C-ENTER on =item line does not move down two lines    CAN'T REPRODUCE

* =over ENTER puts cursor on the *next* line after =item        CAN'T REPRODUCE

* =over SPACE is not electric in the last line of the buffer (not in newer 21.2)


reply via email to

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