From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ilya Zakharevich Newsgroups: gmane.emacs.help Subject: Re: CPerl mode v5.0 Date: Mon, 17 Feb 2003 07:56:52 +0000 (UTC) Organization: U.C. Berkeley Math. Department. Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <841y2gv5zf.fsf@lucy.is.informatik.uni-duisburg.de> <20030211222108.11234512.occitan@esperanto.org> NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1045468734 16005 80.91.224.249 (17 Feb 2003 07:58:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 17 Feb 2003 07:58:54 +0000 (UTC) Bcc: ilya Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18kgAs-00049i-00 for ; Mon, 17 Feb 2003 08:58:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18kgCT-0000Kj-01 for gnu-help-gnu-emacs@m.gmane.org; Mon, 17 Feb 2003 03:00:29 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.berkeley.edu!ucberkeley!agate.berkeley.edu!agate!ilya Original-Newsgroups: gnu.emacs.help Original-Lines: 258 Original-NNTP-Posting-Host: powdermilk.math.berkeley.edu Original-X-Trace: agate.berkeley.edu 1045468612 99982 169.229.140.13 (17 Feb 2003 07:56:52 GMT) Original-X-Complaints-To: usenet@agate.berkeley.edu Original-NNTP-Posting-Date: Mon, 17 Feb 2003 07:56:52 +0000 (UTC) X-How-To-Reach-Me: The From: address is valid X-How-To-Disable-Cc: Put in the headers the line: Mail-Copies-To: never Originator: ilya@powdermilk Original-Xref: shelby.stanford.edu gnu.emacs.help:110261 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6763 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6763 [A complimentary Cc of this posting was sent to Daniel Pfeiffer ], 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 => 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 ;; at line (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)