Subject: 24.0.92; semantic-complete-jump prefers declaration over definition

From: Tom Tromey <[email-masked]>
Date: Thu, 05 Jan 2012 10:48:48 -0700

Consider this .c file:

static int collect_stuff (void);

int main ()
{
  collect_stuff();
}

static int collect_stuff (voi)
{
  return 23;
}

First, M-x semantic-mode.
Put point inside main.
Then 'C-c , J' (semantic-complete-jump) to "collect_stuff".

Semantic will jump to the declaration on line 1.
I think it would be better if it worked like:

* If point is inside a declaration or definition, put that entity at the
  end of the list, and jump to the first item in the list.
  In this example, if point was on line 1, it would jump to the definition;
  and if point is in the definition, it would jump to line 1.
* Otherwise, prefer a definition over any declaration.

In GNU Emacs 24.0.92.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.7)
 of 2011-12-21 on barimba
Windowing system distributor `Fedora Project', version 11.0.11004000
configured using `configure  '--prefix=/home/tromey/Space/EmacsBzr/emacs-mt/install''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
  global-auto-revert-mode: t
  diff-auto-refine-mode: t
  global-semanticdb-minor-mode: t
  global-semantic-idle-scheduler-mode: t
  semantic-idle-scheduler-mode: t
  semantic-mode: t
  shell-dirtrack-mode: t
  bug-reference-prog-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-spelling-mode: t
  erc-truncate-mode: t
  flyspell-mode: t
  erc-status-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
/ / ~ / g n <tab> a r <tab> a r <tab> g d <tab> l i 
n e p <backspace> s p <tab> c <backspace> <tab> c <return> 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-s d e c o 
d e _ C-v C-l C-l C-v C-v M-v M-v M-v C-v C-v C-v C-v 
C-v C-v C-l C-v C-v C-v C-v M-v M-v C-r f C-g C-u C-p 
C-u C-p C-n M-f M-f M-f M-f M-f C-c , J <return> C-s 
C-g C-s C-f C-s C-w C-w C-w C-s C-s C-a C-u C-u C-n 
C-l C-z n C-c C-SPC C-c C-SPC C-c C-SPC C-c C-SPC C-x 
C-f / t m p / s e m . c <return> i n t SPC c o l l 
e c t _ s t u f f SPC ( v o i d ) ; C-a s a t <backspace> 
<backspace> t a t i c SPC C-e <return> <return> i n 
t SPC m a i n S-SPC ( ) <return> { <return> c o l l 
M-/ ( ) ; <return> } <return> <return> v <backspace> 
s t a t i c SPC i n t SPC c o l M-/ SPC ( v o i ) <return> 
{ <return> r e t u r n SPC 2 3 ; <return> } <return> 
C-x C-s C-u C-p C-u C-p C-n M-f C-c , J <return> C-z 
n M-x C-g C-z h C-g C-z n C-h k C-c , J C-x 1 C-n C-u 
C-n C-n C-n C-u C-p C-n M-f C-c , J M-p C-k c o l l 
<tab> <tab> <tab> <tab> <tab> C-g C-g C-z n M-x C-g 
M-x r e p o r t - e m <tab> b <tab> <return>

Recent messages:
syntax: ((topmost-intro 117)), indent: 0
Saving file /tmp/sem.c...
Wrote /tmp/sem.c
Mark set
function: collect_stuff 
Quit [2 times]
Type C-x 1 to delete the help window.
Jump to symbol (default collect_stuff): collect_stuff [1 of 2 matches]
Jump to symbol (default collect_stuff): collect_stuff [2 of 2 matches]
Quit [3 times]
C-c , J runs the command semantic-complete-jump

Load-path shadows:
/home/tromey/lib/lisp/rpm-spec-mode hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/rpm-spec-mode
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/md4 hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/md4
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/hex-util hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/hex-util
/home/tromey/.emacs.d/elpa/css-mode-1.0/css-mode hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/textmodes/css-mode
/home/tromey/.emacs.d/elpa/ruby-mode-1.0/ruby-mode hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/progmodes/ruby-mode
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-uchnm hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-uchnm
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-rap hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-rap
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-uri hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-uri
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-parse hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-parse
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-ns hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-ns
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-enc hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-enc
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/xmltok hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/xmltok
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-nxml hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-nxml
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-maint hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-maint
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-pttrn hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-pttrn
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-match hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-match
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-xsd hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-xsd
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-util hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-util
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-loc hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-loc
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-glyph hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-glyph
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-mode hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-mode
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-outln hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-outln
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-dt hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-dt
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-cmpct hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-cmpct
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-valid hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-valid
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/xsd-regexp hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/xsd-regexp
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-maint hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-maint
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/nxml-parse hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/nxml-parse
/home/tromey/.emacs.d/elpa/nxml-mode-20041004/rng-util hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/nxml/rng-util
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/sasl-digest hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/sasl-digest
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/sasl-ntlm hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/sasl-ntlm
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/sasl hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/sasl
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/ntlm hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/ntlm
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/hmac-def hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/hmac-def
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/sasl-cram hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/sasl-cram
/home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/site-lisp/flim/hmac-md5 hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/net/hmac-md5
/home/tromey/.emacs.d/elpa/emms-3.0/tq hides /home/tromey/Space/EmacsBzr/emacs-mt/install/share/emacs/24.0.92/lisp/emacs-lisp/tq

Features:
(shadow emacsbug semantic/wisent/java-tags semantic/java semantic/doc
semantic/wisent/javat-wy compare-w log-view pcvs-util vc-annotate
iswitchb tcl w3m-form w3m-cookie w3m-bookmark w3m-tabmenu w3m-session
w3m doc-view image-mode w3m-hist w3m-fb w3m-ems w3m-ccl ccl w3m-favicon
w3m-image w3m-proc w3m-util webjump vc-sccs vc-svn vc-rcs vc-dir ewoc
semantic/wisent/python semantic/wisent/python-wy semantic/wisent
semantic/wisent/wisent python-21 python vc ediff-merg ediff-diff
ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff
vc-dispatcher ind-util debug find-func gnus-fun vc-bzr jimb-patch
autorevert gud nroff-mode autoconf autoconf-mode grep goto-addr add-log
copyright smerge-mode newcomment diff-mode gdb-shell semantic/edit etags
find-file semantic/tag-write semantic/tag-file semantic/find
semantic/complete eieio-opt semantic/bovine cus-start cus-load inversion
semantic/db-file cedet-files semantic/bovine/c semantic/decorate/include
semantic/db-find semantic/db-ref semantic/decorate/mode
semantic/decorate pulse semantic/bovine/c-by semantic/lex-spp
semantic/bovine/gcc semantic/dep semantic/analyze semantic/sort
semantic/scope semantic/analyze/fcn semantic/db-mode semantic/db
eieio-base semantic/idle semantic/format ezimage semantic/tag-ls
semantic/ctxt semantic/util-modes semantic/util semantic semantic/tag
semantic/lex semantic/fw mode-local cedet pcmpl-unix pcmpl-gnu shell
vc-cvs texinfo help-mode view dabbrev idutils compile vc-git cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs jka-compr gnus-html url-cache mm-url thai-util thai-word
erc-menu erc-join erc-ring erc-pcomplete pcomplete erc-track erc-match
erc-button erc-fill erc-stamp erc-netsplit erc-spelling erc-truncate
mailalias bbdb-sc supercite regi mail-hist flow-fill multi-isearch
bbdb-hooks shr-color color bbdb-gui mule-util smiley ansi-color
gnus-cite qp shr browse-url gnus-async gnus-bcklg gnus-ml disp-table
nndraft nnmh gnutls parse-time netrc network-stream starttls tls nnml
nnfolder bbdb-gnus bbdb-snarf mail-extr bbdb-com warnings nnnil
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 epg-config mm-view mml-smime smime dig nntp gnus-cache
nnir gnus-sum nnoo gnus-group gnus-undo nnmail mail-source smtpmail
sendmail gnus-start gnus-spec gnus-int gnus-range message idna rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus
gnus-ems nnheader mail-utils wid-edit flyspell ispell eldoc emms-status
emms-lastfm emms-browser sort emms-playlist-sort emms-score
emms-player-xine emms-player-mpd emms-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-util url-parse
auth-source eieio byte-opt bytecomp byte-compile cconv macroexp assoc
gnus-util password-cache url-vars mm-util mail-prsvr mailcap tq
emms-playing-time emms-lyrics derived emms-streams emms-mode-line
emms-cache emms-info-ogginfo emms-info-mp3info emms-info later-do
emms-playlist-mode edmacro kmacro emms-player-mplayer emms-player-simple
emms-source-playlist emms-source-file locate dired emms-setup emms
emms-compat gdb-shell-autoloads nxml-enc pydoc-info-autoloads info-look
info weblogger-autoloads xml-rpc-autoloads package reporter cal-china
lunar solar cal-dst cal-bahai cal-islam cal-hebrew holidays hol-loaddefs
appt diary-lib diary-loaddefs cal-menu easymenu calendar cal-loaddefs
uniquify mouse-sel easy-mmode notifications status cl dbus xml
erc-services erc-networks erc-goodies erc erc-backend erc-compat
format-spec thingatpt pp advice help-fns advice-preload bbdb timezone
ange-ftp comint regexp-opt ring server bbdb-autoloads time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer loaddefs button faces cus-face files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Tom