Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[pid-mode.el] cannot edit

0 views
Skip to first unread message

Jerome Quelin

unread,
Oct 1, 2004, 12:09:37 PM10/1/04
to Perl 6 Internals
Hi,

I tried the pir-mode provided in the editor/ subdir. And when opening a
.imc file (I've associated .pir with pir-mode + font-lock-mode), I
cannot type spaces or carriage returns:

(24) (warning/warning) Error caught in `font-lock-pre-idle-hook':
(invalid-regexp Invalid syntax designator)

And the minibuffer tells me:
Symbol's function definition is void: line-beginning-position

I'm using xemacs 21.4.14

Is the pir-mode.el file complete? Or am I encountering a bug in it?


Jerome
--
jqu...@mongueurs.net

Stéphane Payrard

unread,
Oct 1, 2004, 12:20:33 PM10/1/04
to Jerome Quelin, Perl 6 Internals

This function is defined in emacs:

line-beginning-position is a built-in function.
(line-beginning-position &optional N)

Return the character position of the first character on the current line.
With argument N not nil or 1, move forward N - 1 lines first.
If scan reaches end of buffer, return that position.

The scan does not cross a field boundary unless doing so would move
beyond there to a different line; if N is nil or 1, and scan starts at a
field boundary, the scan stops as soon as it starts. To ignore field
boundaries bind `inhibit-field-text-motion' to t.

This function does not move point.

switch to emacs. :)

>
>
> Jerome
> --
> jqu...@mongueurs.net
>

John Paul Wallington

unread,
Oct 1, 2004, 6:22:53 PM10/1/04
to Jerome Quelin, perl6-i...@perl.org
Jerome Quelin <jqu...@mongueurs.net> writes:

> And the minibuffer tells me:
> Symbol's function definition is void: line-beginning-position
>
> I'm using xemacs 21.4.14

You could put something like:
(defalias 'line-beginning-position 'point-at-bol)
in your XEmacs init file.


How about defining a compatibility alias if necessary like so:

--- pir-mode.el 17 Aug 2004 15:59:49 +0100 1.2
+++ pir-mode.el 01 Oct 2004 23:08:08 +0100
@@ -8,8 +8,11 @@
;; See the documentation of `octave-mode' and `octave-help' for further
;; information.

-(require 'regexp-opt)
;;; Code:
+(require 'regexp-opt)
+(unless (fboundp 'line-beginning-position)
+ (defalias 'line-beginning-position 'point-at-bol))
+
(add-to-list 'auto-mode-alist '("\\.imc\\'" . pir-mode))

(defvar pir-mode-hook nil)

Jerome Quelin

unread,
Oct 2, 2004, 4:06:14 AM10/2/04
to John Paul Wallington, perl6-i...@perl.org
On 04/10/01 23:22 +0100, John Paul Wallington wrote:
> Jerome Quelin <jqu...@mongueurs.net> writes:
> > And the minibuffer tells me:
> > Symbol's function definition is void: line-beginning-position
> > I'm using xemacs 21.4.14
>
> How about defining a compatibility alias if necessary like so:
>
> --- pir-mode.el 17 Aug 2004 15:59:49 +0100 1.2
> +++ pir-mode.el 01 Oct 2004 23:08:08 +0100
> @@ -8,8 +8,11 @@
> ;; See the documentation of `octave-mode' and `octave-help' for further
> ;; information.
>
> -(require 'regexp-opt)
> ;;; Code:
> +(require 'regexp-opt)
> +(unless (fboundp 'line-beginning-position)
> + (defalias 'line-beginning-position 'point-at-bol))
> +
> (add-to-list 'auto-mode-alist '("\\.imc\\'" . pir-mode))
>
> (defvar pir-mode-hook nil)

Ok, we also need this one:
(unless (fboundp 'line-end-position)
(defalias 'line-end-position 'point-at-eol))

Now it works, I can use spaces and returns. But while fontifying, I get:

(5) (warning/warning) Error caught in `font-lock-pre-idle-hook':
(invalid-regexp Invalid syntax designator)


The fontifying looks allright nevertheless.

Jerome
--
jqu...@mongueurs.net

John Paul Wallington

unread,
Oct 2, 2004, 7:33:05 PM10/2/04
to Jerome Quelin, perl6-i...@perl.org
> Now it works, I can use spaces and returns. But while fontifying, I get:
>
> (5) (warning/warning) Error caught in `font-lock-pre-idle-hook':
> (invalid-regexp Invalid syntax designator)

How about this fix:

Index: pir-mode.el
===================================================================
RCS file: /cvs/public/parrot/editor/pir-mode.el,v
retrieving revision 1.2
diff -u -r1.2 pir-mode.el
--- pir-mode.el 17 Aug 2004 14:59:49 -0000 1.2
+++ pir-mode.el 2 Oct 2004 23:38:15 -0000
@@ -270,7 +270,7 @@
(,pir-register-regexp . font-lock-variable-name-face)
(,(regexp-opt pir-dotted-directives 'paren) . font-lock-keyword-face)
(,(regexp-opt pir-ops 'words) . font-lock-keyword-face)
- ("\\s-*\\(\\sw+\\)\\s=*"
+ ("\\s-*\\(\\sw+\\)\\s-*"
(1 font-lock-variable-name-face))
))

Jerome Quelin

unread,
Oct 3, 2004, 3:57:06 AM10/3/04
to John Paul Wallington, perl6-i...@perl.org

Works like a charm. Thanx a lot.
Does it still works with emacs? If yes, then do you have commit rights?

Jerome
--
jqu...@mongueurs.net

John Paul Wallington

unread,
Oct 3, 2004, 7:09:19 AM10/3/04
to Jerome Quelin, perl6-i...@perl.org
> Works like a charm. Thanx a lot.
> Does it still works with emacs?

Yes, as far as I can tell.

> If yes, then do you have commit rights?

I don't have commit rights.

There are further changes I would like to make to pir-mode.el, mostly
simple bug-fixes and clean-ups.

Jerome Quelin

unread,
Oct 3, 2004, 7:41:02 AM10/3/04
to John Paul Wallington, perl6-i...@perl.org

Then, send the whole patch and I'll apply it for you.

Jerome
--
jqu...@mongueurs.net

John Paul Wallington

unread,
Oct 3, 2004, 10:10:45 AM10/3/04
to Jerome Quelin, perl6-i...@perl.org
> > There are further changes I would like to make to pir-mode.el, mostly
> > simple bug-fixes and clean-ups.
>
> Then, send the whole patch and I'll apply it for you.

Here you go:

--- pir-mode.el 17 Aug 2004 15:59:49 +0100 1.2

+++ pir-mode.el 03 Oct 2004 15:03:28 +0100
@@ -5,19 +5,34 @@
;; This package provides Emacs support for PIR.
;; It defines PIR mode, a major mode for editing PIR code.

-;; See the documentation of `octave-mode' and `octave-help' for further
-;; information.
+;; To begin using this mode for all `.imc' files that you edit,
+;; put this file in your `load-path' and add the following lines
+;; to your `.emacs' file:
+
+;; (autoload 'pir-mode \"pir-mode\" nil t)


+;; (add-to-list 'auto-mode-alist '("\\.imc\\'" . pir-mode))

+
+;; If you have any problems with this, you're on your own,
+;; You could always try asking on perl6-i...@perl.org.

-(require 'regexp-opt)
;;; Code:
-(add-to-list 'auto-mode-alist '("\\.imc\\'" . pir-mode))
+(require 'regexp-opt)
+(require 'cl)

-(defvar pir-mode-hook nil)


+(unless (fboundp 'line-beginning-position)
+ (defalias 'line-beginning-position 'point-at-bol))

+(unless (fboundp 'line-end-position)
+ (defalias 'line-end-position 'point-at-eol))

(defgroup pir nil
"Mode for editing PIR code."
:group 'languages)

+(defcustom pir-mode-hook nil
+ "*Hook run when entering PIR mode."
+ :type 'hook
+ :group 'pir)
+
(defcustom pir-comment-char ?#
"*The `comment-start' character assumed by PIR mode."
:type 'character
@@ -27,7 +42,36 @@
"*The default comment column for PIR code."
:type 'integer
:group 'pir)
-
+
+(defcustom pir-block-comment-start
+ (concat (make-string 2 pir-comment-char) " ")
+ "String to insert to start a new PIR comment on an empty line."
+ :type 'string
+ :group 'pir)
+
+(defcustom pir-auto-indent-flag nil
+ "*Non-nil means indent line after a semicolon or space in PIR mode."
+ :type 'boolean
+ :group 'pir)
+
+(defcustom pir-auto-newline nil
+ "*Non-nil means automatically newline after a semicolon in PIR mode."
+ :type 'boolean
+ :group 'pir)
+
+(defcustom pir-blink-matching-block t
+ "*Control the blinkin of matching PIR block keywords.
+Non-nil means show matching begin of block when inserting a space,
+newline or semicolon after an end keyword."
+ :type 'boolean
+ :group 'pir)
+
+(defcustom pir-basic-indent 8
+ "*Extra indentation applied to statements in PIR block structures."
+ :type 'integer
+ :group 'pir)
+
+
(defvar pir-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c;" 'pir-comment-region)
@@ -53,7 +97,6 @@
(define-key map "\C-c\M-\C-h" 'pir-mark-block)
(define-key map "\C-c]" 'pir-close-block)
(define-key map "\C-c\C-f" 'pir-insert-defun)
-
map)
"Keymap for PIR major mode.")

@@ -88,9 +131,7 @@
"Menu for PIR mode.")


-(defvar pir-mode-syntax-table nil
- "Syntax table for PIR major mode.")
-(setq pir-mode-syntax-table
+(defvar pir-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?_ "w" st)
(modify-syntax-entry ?\\ "\\" st)
@@ -99,7 +140,8 @@
(modify-syntax-entry ?$ "'" st)
(modify-syntax-entry ?, "." st)
(modify-syntax-entry ?. ". p" st)
- st))
+ st)
+ "Syntax table for PIR major mode.")

(defvar pir-PMC-keyword-symbols
'("Array" "Boolean" "Compiler" "Continuation" "Coroutine" "CSub"
@@ -175,127 +217,96 @@
(defvar pir-register-regexp "[INPS]\\([12][0-9]\\|3[01]\\|[0-9]\\)")
(defvar pir-dollar-register-regexp "\\$[INPS][0-9]+")

-(defvar pir-directives)
-(setq pir-directives
- '("method" "non_prototyped" "prototyped" "@LOAD" "@MAIN"))
+(defvar pir-directives
+ '("method" "non_prototyped" "prototyped" "@LOAD" "@MAIN"))

-(defvar pir-dotted-directives)
-(setq pir-dotted-directives
+(defvar pir-dotted-directives
'(".sub" ".pcc_sub" ".end" ".emit" ".eom" ".const" ".namespace"
".endnamespace" ".result" ".arg" ".return" ".include"
".pcc_begin" ".pcc_end" ".pcc_begin_return" ".pcc_end_return"
".pcc_begin_yield" ".pcc_end_yield"))

-(defvar pir-variable-declarations)
-(setq pir-variable-declarations
- '(".local" ".sym" ".param"))
+(defvar pir-variable-declarations
+ '(".local" ".sym" ".param"))

-(defvar pir-begin-keywords)
-(setq pir-begin-keywords
+(defvar pir-begin-keywords
'(".sub" ".emit" ".pcc_begin_yield" ".pcc_begin_return"
".pcc_begin" ".namespace"))

-(defvar pir-end-keywords)
-(setq pir-end-keywords
+(defvar pir-end-keywords
'(".end" ".eom" ".pcc_end_yield" ".pcc_end_return"
".pcc_end" ".endnamespace"))

-(defvar pir-block-match-alist)
-(setq pir-block-match-alist
+(defvar pir-block-match-alist
'((".sub" ".end" 1)
(".emit" ".eom" 1)
(".pcc_begin_yield" ".pcc_end_yield" 0)
(".pcc_begin_return" ".pcc_end_return" 0)
(".pcc_begin" ".pcc_end" 0)
- (".namespace" ".endnamespace" 0)))
-; "Alist with IMCC's matching block keywords.
-;Has IMCC's begin keywords as keys and a list of the matching end keywords as
-;associated values.")
-
-(defvar pir-block-offset-alist)
-(setq pir-block-offset-alist
- (mapcan (lambda (blockspec)
- (let ((offset (caddr blockspec)))
- `((,(car blockspec) . ,offset)
- (,(cadr blockspec) . ,offset))))
- pir-block-match-alist))
+ (".namespace" ".endnamespace" 0))
+ "Alist of IMCC's matching block keywords.
+Has IMCC's begin keywords as keys and a list of the matching end keywords as
+associated values.")
+
+(defvar pir-block-offset-alist
+ (mapcan (lambda (blockspec)
+ (let ((offset (caddr blockspec)))
+ `((,(car blockspec) . ,offset)
+ (,(cadr blockspec) . ,offset))))
+ pir-block-match-alist))

-(defvar pir-open-directives)
-(setq pir-open-directives
+(defvar pir-open-directives
(mapcar #'car pir-block-match-alist))

-(defvar pir-close-directives)
-(setq pir-close-directives
+(defvar pir-close-directives
(mapcar #'cadr pir-block-match-alist))

-(defvar pir-block-begin-regexp)
-(setq pir-block-begin-regexp
- (regexp-opt pir-begin-keywords 'paren))
-(defvar pir-block-end-regexp)
-(setq pir-block-end-regexp
- (regexp-opt pir-end-keywords 'paren))
-(defvar pir-block-begin-or-end-regexp)
-(setq pir-block-begin-or-end-regexp
- (concat "\\(?:"pir-block-begin-regexp "\\|"
- pir-block-end-regexp "\\)"))
-
-(defvar pir-function-header-regexp)
-(setq pir-function-header-regexp
- "\\.\\(.sub\\)\\s-+\\(\\sw+\\)")
-; "Regexp to match a PIR function header.")
-
-
-(defvar pir-font-lock-keywords)
-(setq pir-font-lock-keywords
- `((,(concat "^\\s *\\(.sub\\)\\s +\\(\\sw+\\)"
- "\\(\\s +" (regexp-opt pir-directives 'paren) "\\)?")
- (1 font-lock-keyword-face)
- (2 font-lock-function-name-face t t)
- (4 font-lock-keyword-face t t))
- (,(concat "\\s-*" (regexp-opt pir-variable-declarations 'paren)
- "\\(?:\\s +" (regexp-opt pir-type-keywords 'paren)
- "\\(?:\\s +\\(\\sw+\\)\\)?\\)?")
- (1 font-lock-keyword-face)
- (2 font-lock-type-face nil t)
- (3 font-lock-variable-name-face nil t))
- (,(concat "^\\s *\\(.const\\)\\s +"
- (regexp-opt pir-type-keywords 'paren)
- "\\(\\s +\\(\\sw+\\)\\)?")
- (1 font-lock-keyword-face)
- (2 font-lock-type-face nil t)
- (4 font-lock-constant-face nil t))
- (,pir-block-begin-or-end-regexp . font-lock-keyword-face)
-
- (,pir-dollar-register-regexp . font-lock-variable-name-face)
- (,pir-register-regexp . font-lock-variable-name-face)
- (,(regexp-opt pir-dotted-directives 'paren) . font-lock-keyword-face)
- (,(regexp-opt pir-ops 'words) . font-lock-keyword-face)


- ("\\s-*\\(\\sw+\\)\\s=*"

- (1 font-lock-variable-name-face))
- ))
-
-(defcustom pir-auto-indent-flag nil
- "*Non-nil means indent line after a semicolon or space in PIR mode."
- :type 'boolean
- :group 'pir)
+(defvar pir-block-begin-regexp
+ (regexp-opt pir-begin-keywords 'paren))

-(defcustom pir-blink-matching-block t
- "*Control the blinkin of matching PIR block keywords.
-Non-nil means show matching begin of block when inserting a space,
-newline or semicolon after an end keyword."
- :type 'boolean
- :group 'pir)
+(defvar pir-block-end-regexp
+ (regexp-opt pir-end-keywords 'paren))

-(defcustom pir-basic-indent 8
- "*Extra indentation applied to statements in PIR block structures."
- :type 'integer
- :group 'pir)
+(defvar pir-block-begin-or-end-regexp
+ (concat "\\(?:" pir-block-begin-regexp "\\|"
+ pir-block-end-regexp "\\)"))
+
+(defvar pir-function-header-regexp "\\.\\(.sub\\)\\s-+\\(\\sw+\\)"
+ "Regexp to match a PIR function header.")
+
+(defvar pir-font-lock-keywords
+ `((,(concat "^\\s *\\(.sub\\)\\s +\\(\\sw+\\)"
+ "\\(\\s +" (regexp-opt pir-directives 'paren) "\\)?")
+ (1 font-lock-keyword-face)
+ (2 font-lock-function-name-face t t)
+ (4 font-lock-keyword-face t t))
+ (,(concat "\\s-*" (regexp-opt pir-variable-declarations 'paren)
+ "\\(?:\\s +" (regexp-opt pir-type-keywords 'paren)
+ "\\(?:\\s +\\(\\sw+\\)\\)?\\)?")
+ (1 font-lock-keyword-face)
+ (2 font-lock-type-face nil t)
+ (3 font-lock-variable-name-face nil t))
+ (,(concat "^\\s *\\(.const\\)\\s +"
+ (regexp-opt pir-type-keywords 'paren)
+ "\\(\\s +\\(\\sw+\\)\\)?")
+ (1 font-lock-keyword-face)
+ (2 font-lock-type-face nil t)
+ (4 font-lock-constant-face nil t))
+ (,pir-block-begin-or-end-regexp . font-lock-keyword-face)
+
+ (,pir-dollar-register-regexp . font-lock-variable-name-face)
+ (,pir-register-regexp . font-lock-variable-name-face)
+ (,(regexp-opt pir-dotted-directives 'paren) . font-lock-keyword-face)
+ (,(regexp-opt pir-ops 'words) . font-lock-keyword-face)


+ ("\\s-*\\(\\sw+\\)\\s-*"

+ (1 font-lock-variable-name-face)))
+ "Expressions to highlight in PIR mode.")

(defvar pir-imenu-generic-expression
(list
(list nil pir-function-header-regexp 2))
"Imenu expression for PIR mode. See `imenu-generic-expression'.")
-
+
(defun pir-comment ()
"Convert an empty comment to a `larger' kind, or start a new one.
These are the known comment classes:
@@ -377,7 +388,7 @@

Keybindings
===========
-\\{octave-mode-map}
+\\{pir-mode-map}

Variables you can use to customize PIR mode
===========================================
@@ -399,8 +410,7 @@
following lines to your `.emacs' file:

(autoload 'pir-mode \"pir-mode\" nil t)
- (setq auto-mode-alist
- (cons '(\"\\\\.imc$\" . pir-mode) auto-mode-alist))


+ (add-to-list 'auto-mode-alist '(\"\\\\.imc\\\\'\" . pir-mode))

If you have any problems with this, you're on your own. You could always
try asking on perl6-i...@perl.org."
@@ -409,14 +419,14 @@
(use-local-map pir-mode-map)
(setq major-mode 'pir-mode)
(setq mode-name "PIR")
-
+
(set-syntax-table pir-mode-syntax-table)
-
+
(setlocalq font-lock-defaults '(pir-font-lock-keywords))
(setlocalq indent-line-function 'pir-indent-line)
- (setlocalq pir-mode-basic-indent 'pir-mode-basic-indent)
+ (setlocalq pir-basic-indent pir-basic-indent)
(setlocalq require-final-newline t)
-
+
(setlocalq comment-start "# ")
(setlocalq comment-end "")
(setlocalq comment-column pir-comment-column)
@@ -430,8 +440,6 @@
(setlocalq fill-paragraph-function 'pir-fill-paragraph)
(setlocalq adaptive-fill-regexp nil)
(setlocalq fill-column 72)
-
- (setlocalq font-lock-defaults '(pir-font-lock-keywords))

(setlocalq imenu-generic-expression pir-imenu-generic-expression)
(setq imenu-case-fold-search nil)
@@ -440,7 +448,7 @@

(pir-initialize-completions)
(pir-add-pir-menu)
-
+
(run-hooks 'pir-mode-hook))

(defun pir-describe-major-mode ()
@@ -508,8 +516,8 @@
(defun pir-uncomment-region (beg end &optional arg)
"Uncomment each line in the region as PIR code."
(interactive "r\nP")
- (or arg (setq arg1))
- (octave-comment-region beg end (- arg)))
+ (or arg (setq arg 1))
+ (pir-comment-region beg end (- arg)))


;;; Indentation
@@ -1163,8 +1171,6 @@
(easy-menu-add pir-mode-menu-map pir-mode-map))


-
-(provide 'pir-mode)
(provide 'pir-mode)

;;; pir-mode.el ends here

Jerome Quelin

unread,
Oct 3, 2004, 10:54:44 AM10/3/04
to John Paul Wallington, perl6-i...@perl.org
On 04/10/03 15:10 +0100, John Paul Wallington wrote:
> > > There are further changes I would like to make to pir-mode.el, mostly
> > > simple bug-fixes and clean-ups.
> > Then, send the whole patch and I'll apply it for you.
> Here you go:
[snip]
> ;;; pir-mode.el ends here

Applied with due credits.

Thank you,
Jerome
--
jqu...@mongueurs.net

Piers Cawley

unread,
Oct 4, 2004, 4:39:59 PM10/4/04
to st...@payrard.net, Jerome Quelin, Perl 6 Internals
Stéphane Payrard <st...@payrard.net> writes:

Or patch pir-mode.el, your choice.

Aaron Sherman

unread,
Oct 5, 2004, 10:30:25 AM10/5/04
to Piers Cawley, Perl 6 Internals
On Mon, 04 Oct 2004 21:39:59 +0100, Piers Cawley <pdca...@bofh.org.uk> wrote:
> Stéphane Payrard <st...@payrard.net> writes:
>
> > On Fri, Oct 01, 2004 at 06:09:37PM +0200, Jerome Quelin wrote:
> > This function is defined in emacs:
> >
> > line-beginning-position is a built-in function.
> > (line-beginning-position &optional N)

> > switch to emacs. :)


>
> Or patch pir-mode.el, your choice.

That should be something like:

(defun line-beginning-position (&optional n)


"Return the character position of the first character on the current line.
With argument N not nil or 1, move forward N - 1 lines first.
If scan reaches end of buffer, return that position."

(save-excursion
(beginning-of-line)
(if n (next-line n))
(point)))

no?

--
Aaron Sherman
Senior Systems Engineer and Toolsmith
AaronJ...@gmail.com or a...@ajs.com

Aaron Sherman

unread,
Oct 5, 2004, 2:12:24 PM10/5/04
to John Paul Wallington, Perl6 Internals List
On Fri, 2004-10-01 at 18:22, John Paul Wallington wrote:
> Jerome Quelin <jqu...@mongueurs.net> writes:
>
> > And the minibuffer tells me:
> > Symbol's function definition is void: line-beginning-position
> >
> > I'm using xemacs 21.4.14
>
> You could put something like:
> (defalias 'line-beginning-position 'point-at-bol)
> in your XEmacs init file.

Sorry, I missed that comment before I wrote my own. Good catch.

--
781-324-3772
a...@ajs.com
http://www.ajs.com/~ajs

Jerome Quelin

unread,
Oct 6, 2004, 5:13:28 AM10/6/04
to Aaron Sherman, Piers Cawley, Perl 6 Internals
On 04/10/05 10:30 -0400, Aaron Sherman wrote:
> On Mon, 04 Oct 2004 21:39:59 +0100, Piers Cawley <pdca...@bofh.org.uk> wrote:
> > Stéphane Payrard <st...@payrard.net> writes:
> > > switch to emacs. :)
> > Or patch pir-mode.el, your choice.
> That should be something like:
[snip]
> no?

John Paul Wallington already provided a patch that's been applied.

Thanks anyway,
Jerome
--
jqu...@mongueurs.net

0 new messages