Menu

#47 Small patch to retore line number links

Experimental
open
nobody
None
5
2015-01-31
2014-09-09
No

Markup.pm.orig 2013-11-08 02:38:19.000000000 -0600
--- Markup.pm.new 2014-09-09 15:25:35.023168270 -0500
*** sub markupfile {
288,299 ****
# 2: ''
# Later, it only needs to insert line numbers betwwen 0-1 and 1-2 to
# have the correct anchor.
! &fileref(1, 'fline', $pathname, 1) =~ m/^(<a.*?)href.*\#(\\d+)(\\">)\d+(<\/a>)$/;
my @ltag;
$ltag[0] = $1 . 'name="';
! my $line = $2;
! $ltag[1] = $3;
! $ltag[2] = $4 . ' ';

    # As an optimisation, the skeleton of the <A> link marking for an
    # identifier will be cached in the $lang object.

--- 288,302 ----
# 2: ''
# Later, it only needs to insert line numbers betwwen 0-1 and 1-2 to
# have the correct anchor.
! &fileref(1, 'fline', $pathname, 1) =~ m/^(<a.*?)(href.*\#)(\\d+)(\\">)\d+(<\/a>)$/;
my @ltag;
$ltag[0] = $1 . 'name="';
! my $line = $3;
! $ltag[1] = '" '. $2;
! my $line = $3;
! $ltag[2] = '" >';
! my $line = $3;
! $ltag[3] = $5 . ' ';

    # As an optimisation, the skeleton of the <A> link marking for an
    # identifier will be cached in the $lang object.

Discussion

  • Andre-Littoz

    Andre-Littoz - 2014-09-10

    Hello Patrick,

    Could you explain the rationale behind your patch? It creates an "idempotent" link to the line (it makes the line point to itself) which IMHO has little usefulness. It also has a performance impact in the browser which must record and manage many potential links (think e.g. of some huge files in the kernel with thousands of lines).

    This was the historical behaviour but it was removed several years ago on the basis of the above arguments. Support request #19 (https://sourceforge.net/p/lxr/support-requests/19/) addresses the same topic.

    Regards

     
    • Patrick Gartung

      Patrick Gartung - 2014-09-10

      Hi,

      I made this patch at the request of a developer who missed this feature
      when I moved from v0.9.8 to v2.0.2. He wanted to be able to send a link
      to a specific line in a source file by copying the link.

      Patrick

       

      Last edit: Patrick Gartung 2014-09-10
  • Andre-Littoz

    Andre-Littoz - 2014-09-10

    Hi,

    Looks like your developer was the requester of #19 ;-)

    I nevertheless think that this feature is not generally desirable for the reason explained previously. I won't incorporate your patch in the main line (unless the crowd massively complains about it), however it is here for those who want to implement it.

    There is also a workaround even if it looks user-unfriendly at first sight:
    - copy the URL from the browser address bar,
    - paste it into your file or message
    - remove the eventual fragment-id (the #9999 at the end of the URL)
    - add a fragment-id #9999 at the end of the URL (where 9999 is the desired line number)

    This manual procedure imposes less strain on LXR to generate the HTML page and on the browser which handles fewer links.

    REMEMBER that line numbers must have at least 4 digits, i.e. write #0012 for line 12. "Line numbers" are NOT numbers but strings of characters, therefore 12 is a different anchor than 0012.

    Best regards,
    Andre

     
  • Juraj Variny

    Juraj Variny - 2015-01-31

    I am in favor of this. Github provides anchors to every line and people got used to it - right click on line number, copy url to clipboard, instead of manually editing it. I am not aware of any browser problems due to this.

     
  • Andre-Littoz

    Andre-Littoz - 2015-01-31

    For some time now, I was thinking of improving LXR usefulness at reading and understanding other's programs. Namely, a feature is missing: the ability to comment a source file and store these comments in the DB.

    My idea for implementing it while keeping the design principle of using a web browser for display (hence emitting HTML) was to pluck an <a> link under the line number so that there a visual indication that the line has a comment (when hidden). The <a> link would lead to an "edit" form for the comment.

    Restoring the line number link as requested by the user community would conflict with this feature.

    To be honest, I have not yet written any specification for the comment feature. I'm working on an improvement of parsing speed and accuracy. Exploring this avenue is time-consuming. But it would likely need a complete rewrite.

    Given the use case, I'm ready to restore the line links but I'd appreciate suggestions for the comment feature. I'll open a discussion topic for it.

     

Log in to post a comment.