ada-mode-users
[Top][All Lists]
Advanced

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

Re: [Ada-mode-users] [patch] ada-goto-declaration when point is on an op


From: Ludovic Brenta
Subject: Re: [Ada-mode-users] [patch] ada-goto-declaration when point is on an operator
Date: Fri, 27 Jan 2017 12:39:32 +0100
User-agent: Roundcube Webmail/0.5.3

On Tue, 08 Nov 2016 18:47:42 +0200, Ludovic Brenta wrote:
Hello,

Consider the following line:

    Set_Model (Tree.View, +Tree.Store); -- line 3775

ada-goto-declaration has two bugs which this patch corrects.

First, if point is inside the second occurrence of "Tree",
ada-identifier-at-point skips backward until point is on the + and
then it returns the string "+".  With my patch,
ada-identifier-at-point correctly moves point to the T and returns
"Tree" instead.

Second, if ada-gnat-xref-other receives an identifier which is an
operator (e.g. it receives the string "+"), it calls gnat find like
so:

First of all, thank you for applying the patch that I sent in
ada-mode 5.2.1.  However I have discovered a third bug which is
still present (I don't know if it is a regression introduced by my
patch or a pre-existing bug).  This is triggered by identifiers
whose name start with the name of an operator; for example:

  Modify (Absolute_Temperature);
  Nothing_Changed;

If point is at the start of "Modify", ada-goto-declaration tries to
jumps to an operator "mod" which may exit, or not; similarly if point
is at the start of "Absolute_Temperature" it looks for "abs",
Nothing_Changed goes to "not", Origin goes to "or", etc.

This micro-patch fixes by enclosing the operators in word delimiters,
\\< and \\>.  It is still not perfect, as "_" is a word delimiter,
so "This_Or_That" will still jump to "or" if point is in the "Or".
Suggestions for improvement welcome.

--- ada-mode/ada-mode.el        2016-12-22 23:02:01.000000000 +0100
+++ ada-mode/ada-mode.el        2017-01-27 12:03:53.000000000 +0100
@@ -2126,7 +2126,7 @@
   )

 (defvar ada-operator-re
- "\\+\\|-\\|/\\|\\*\\*\\|\\*\\|=\\|&\\|abs\\|mod\\|rem\\|and\\|not\\|or\\|xor\\|<=\\|<\\|>=\\|>" + "\\+\\|-\\|/\\|\\*\\*\\|\\*\\|=\\|&\\|\\<\\(abs\\|mod\\|rem\\|and\\|not\\|or\\|xor\\)\\>\\|<=\\|<\\|>=\\|>"
   "Regexp matching Ada operator_symbol.")

 (defun ada-identifier-at-point ()

--
Ludovic Brenta.




reply via email to

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