Is there a way to make links to functions in a notebook?

If the first appearance of the Symbol in the Notebook is the definition, or close enough to the definition to be convenient, you could use the following Palette button to find that first appearance for whatever token the cursor is within.

With[{nb := SelectedNotebook[]},
  DynamicModule[{token},
    Button["Find First",
      SelectionMove[nb, All, Word];
      token = NotebookRead @ nb;
      SelectionMove[nb, Before, Notebook];
      NotebookFind[nb, token]
    ]
  ] // CreatePalette
]

For more control you can add a Cell Tag that is identical to the function name to the cell that contains the definition, then use this Palette button to jump to that specific Cell:

With[{nb := SelectedNotebook[]},
  DynamicModule[{token},
    Button["Jump to Tag",
      SelectionMove[nb, All, Word];
      token = NotebookRead @ nb;
      SelectionMove[nb, Before, Notebook];
      NotebookFind[nb, token, Next, CellTags]
    ]
  ] // CreatePalette
]

Similar approach to Mr.Wizard's but searching only code and input cells. Put that procedure inside joker.m file, as described in 72914 or as a procedure for Button in a Palette.

Module[{name, nb},
 nb = InputNotebook[];
 Label["readName"];
 name = NotebookRead[nb];
 If[name === {},
  FrontEndExecute@FrontEndToken[nb, "ExpandSelection"]; 
  Goto["readName"]
  ];
 (
    SelectionMove[#, Before, CellContents, AutoScroll -> False]; 
    If[NotebookFind[#, name, WordSearch -> True] =!= $Failed, Abort[]]
    ) & /@ Cells[nb, CellStyle -> {"Input", "Code"}]
 ]

I augmented Mr.Wizard's answer with a "Back" button:

With[{nb:=SelectedNotebook[]},
    DynamicModule[{token,backcell},
        Column[{
            Button["Find First",

            (* Expand selection to whole word *)
            SelectionMove[nb,All,Word];

            (* Create notebook sub-object based on current selection *)
            token=NotebookRead@nb;

            (* Expand selection to whole cell *)
            SelectionMove[nb,All,Cell];

            (* Remember where we came from *)
            backcell=NotebookRead@nb;

            (* Move cursor to top of file *)
            SelectionMove[nb,Before,Notebook];

            (* Move cursor to where sub-object 'token' appears *)
            NotebookFind[nb,token]],

            Button["Back",NotebookFind[nb,backcell]]
        }]]//CreatePalette]

Tags:

Notebooks