Skip Menu |

This queue is for tickets about the perltidy-mode CPAN distribution.

Report information
The Basics
Id: 36371
Status: new
Priority: 0/
Queue: perltidy-mode

People
Owner: Nobody in particular
Requestors: haraldme [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Xemacs-ism in function point->line
Date: Mon, 2 Jun 2008 18:03:54 +0200
To: bug-perltidy-mode [...] rt.cpan.org
From: "Harald Meland" <haraldme [...] gmail.com>
Hi, In perltidy-mode 0.02, the function 'point->line' makes use of the 'incf' function. This function appears to be defined on Xemacs (version 21.4 on Ubuntu 7.10 (gutsy)), but on GNU Emacs one has to explicitly load the 'cl' package before 'incf' can be used. One could also argue that the current definition of the 'point->line' function is buggy, as it will only do what its docstring says when point is at the beginning of a line. I'm not sure whether or not this is a feature or a bug with respect to the function's usage in perlcritic-mode. I think the more-or-less-standard way of doing such line-counting in an emacs-variant-independent way is to use 'count-lines', i.e. something like this: (defun point->line (point) "Get the line number that POINT is on." ; I'm not bothering to use save-excursion because I think I'm ; calling this function from inside other things that are likely to ; use that and all I really need to do is restore my current ; point. So that's what I'm doing manually. (let ((start (point-min)) (original-point (point))) (goto-char point) ;; Move point to beginning of current line. (forward-line 0) (prog1 (1+ (count-lines start (point))) (goto-char original-point)))) Thanks for making perlcritic-mode, I find it very useful. Regards, -- Harald