Subject: bug#20061: 24.4; complete-tag at end of buffer fails

From: Johan Claesson <[email-masked]>
Date: Sun, 08 Mar 2015 20:45:50 +0100

Hi,

Running complete-tag at end of buffer will fail with end-of-buffer
error.  This happens if there is something before point that should have
been able to be expanded by complete-tag.  Below is a suggestion for
correction. 

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index b89b4cf..2c6cf24 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -809,7 +809,8 @@ If no tags table is loaded, do nothing and return nil."
          beg)
       (when pattern
        (save-excursion
-          (forward-char (1- (length pattern)))
+          (forward-char (min (- (point-max) (point))
+                             (1- (length pattern))))
           (search-backward pattern)
           (setq beg (point))
           (forward-char (length pattern))

Regards,

/Johan

In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, X toolkit)
 of 2014-10-26 on goblin
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
System Description:	Ubuntu 14.10

Configured using:
 `configure --prefix=/ssd/home/jcl/usr --with-x-toolkit=lucid
 --without-toolkit-scroll-bars -C --without-compress-info
 --enable-link-time-optimization'

Important settings:
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Debbugs

Minor modes in effect:
  display-time-mode: t
  minibuffer-depth-indicate-mode: t
  minibuffer-electric-default-mode: t
  icomplete-mode: t
  diff-auto-refine-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  shell-dirtrack-mode: t
  winner-mode: t
  ido-everywhere: t
  which-function-mode: t
  electric-layout-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-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
  temp-buffer-resize-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<return> <return> <M-delete> M-x <up> <return> 1 0 
<return> <M-delete> <down> <down> M-f M-f C-h f <return> 
M-x d e b u g <tab> <tab> <backspace> <backspace> b 
u g <tab> <tab> g n u <return> <return> 2 1 1 6 <return> 
C-s c o m p l e <left> <return> SPC n n n n n q C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s M-1 C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-a <home> M-x <up> C-g C-q C-SPC M-. 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> C-v C-v C-v C-1 TAB <up> <up> <up> <return> 
<down> <down> M-x <up> C-e - s e r a <tab> <backspace> 
<backspace> a r <tab> <return> c o p <backspace> <backspace> 
o m p l e t e SPC e n d SPC o f SPC e <backspace> b 
u f f e r <return> <return> <C-tab> <next> <prior> 
M-x <up> <return> c o m p l e t e <return> <return> 
<C-tab> <up> C-s e n d <backspace> <backspace> <backspace> 
<backspace> <C-up> <C-up> <C-up> <prior> <C-down> <C-down> 
<C-down> <C-down> <C-down> <C-tab> C-s C-s C-a C-w 
<down> <down> <home> C-s e n d C-s C-s C-s C-s C-s 
C-s C-s C-s C-a M-x r e p o r t - e m <tab> b <tab> 
<return>

Recent messages:
Opening nndoc server on /tmp/gnus-temp-group-588Bxc-ephemeral...done
Mark saved where search started
Mark set
Quit
Contacting host: debbugs.gnu.org:80 [3 times]
Unknown symbol: 涂
Unknown symbol: 坚
Mark saved where search started
Mark set
Mark saved where search started

Load-path shadows:
/home/jcl/share/elisp/gitconfig-mode hides /home/jcl/elpa/gitconfig-mode-20140605.520/gitconfig-mode

Features:
(emacsbug nndoc crm tree-widget elp inferior-slime slime-banner
slime-enclosing-context slime-cl-indent cl-indent gud apropos gnus-fun
make-mode scheme tramp-cache tramp-sh vc-bzr vc-sccs vc-svn vc-cvs
vc-rcs vc-dir vc vc-dispatcher mailalias cal-move cal-iso nnir
gnus-draft w3m-form tempo company-dabbrev company-template company
haskell haskell-load haskell-commands highlight-uses-mode
haskell-modules haskell-sandbox haskell-repl haskell-debug
haskell-interactive-mode haskell-presentation-mode haskell-show
haskell-collapse haskell-navigate-imports haskell-compile
haskell-process haskell-str haskell-session haskell-font-lock rng-loc
rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util org-table esh-var esh-io esh-cmd esh-opt
esh-ext esh-proc esh-arg esh-groups eshell esh-module esh-mode esh-util
org-id ob-octave autoload lisp-mnt tar-mode gnutls url-handlers epg
nnrss shadow gnus-dired eieio-opt speedbar sb-image ezimage dframe
git-commit-mode log-edit pcvs-util footnote misearch multi-isearch
tabify gitconfig-mode conf-mode sort gnus-cite flow-fill mm-archive
mail-extr gnus-async add-log time-stamp url-cache w3m-cookie smiley
jcl-replace jcl-games-init jcl-muse-init htmlize-hack htmlize muse-latex
muse-html muse-xml-common muse-colors cus-edit cus-start cus-load
muse-publish muse-project muse-protocols muse-regexps muse
muse-nested-tags muse-mode jcl-yaoddmuse-init yaoddmuse-extension
yaoddmuse skeleton sgml-mode jcl-renegade-goblin jcl-home-boot
network-stream mule-util vc-git org-rmail org-mhe org-irc org-info
org-gnus org-docview org-bibtex bibtex org-bbdb org-w3m jcl-load
jcl-billboard-init jcl-elisp-init profiler pcase tagbag-init
jcl-grep-init jcl-safe-init jcl-abbrev-init jcl-ediff-init jcl-term-init
jcl-erlang-init jcl-sbg jcl-erlang-log bookmark erlang-eunit
jcl-erlang-man man jcl-midnite-init jcl-midnite midnight
jcl-picpocket-init picpocket-test jcl-erc-init jcl-ido-init
jcl-dired-init image-file wdired jcl-register-init
jcl-command-subset-init jcl-generic-init generic-x jcl-eww-init eww
mm-url shr jcl-org-init poporg ob-latex ob-sh ox-beamer org-feed
org-capture jcl-haskell-init jcl-haskell-old inf-haskell haskell-cabal
haskell-utils haskell-decl-scan haskell-mode haskell-string
haskell-sort-imports haskell-align-imports haskell-compat
haskell-complete-module flymake dabbrev haskell-customize
jcl-mentor-init mentor xml-rpc url-scgi jcl-google-init jcl-modes-init
calc calc-loaddefs calc-macs jcl-rfc rfcview goto-addr proced nroff-mode
table picture python rx jcl-ruby inf-ruby ruby-mode fpl cc-langs cwarn
grep jcl-elpa-init view jcl-global-init time printing mb-depth
whitespace ffap saveplace num3-mode minibuf-eldef icomplete jcl-sl-init
jcl-keys-init diff-mode jcl-sbg-ssit jcl-google google-translate
google-translate-default-ui google-translate-core-ui
google-translate-core jcl-imenu jcl-wesnoth wesnoth-mode
wesnoth-wml-data wesnoth-update jcl-erlang distel-ie edb distel
jcl-picpocket jcl-goblin jcl-dired jcl-dired-lexical picpocket dired-aux
fuzzy-match jcl-ediff jcl-elisp jcl-grep edebug jcl-stumpwm jcl-org
jcl-erc erc-list erc-menu erc-join erc-ring erc-networks erc-pcomplete
erc-track erc-match erc-button erc-fill erc-stamp erc-netsplit
erc-goodies erc erc-backend erc-compat jcl-vbox jcl-keys tramp
tramp-compat tramp-loaddefs trampver shell windmove jcl-isearch
jcl-sbg-scan sbg filecache jcl-bugfix derived loadhist jcl-debbugs
debbugs-org debbugs-gnu debbugs soap-client url-http tls url-auth url-gw
warnings jcl-merge jcl-wip jcl-work-buffer ediff-merg ediff-wind
ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff jcl-sty
jcl-epresent face-remap org-indent epresent ox-latex ox-icalendar
ox-html ox-ascii ox-publish ox org-element diet ps-print ps-def lpr
jcl-eel bindat patmatch erl-service derl epmd net-fsm erl erlext
jcl-template jcl-copyright jcl-template-lib cperl-mode cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
jcl-sbg-tags tagbag erlang wc-mode jcl-register jcl-advice
jcl-command-subset jcl-duff clearcase tq reporter jcl-motion
jcl-site-start jpt-mode erlang-start qp parse-time gnus-ml gnus-topic
nndraft nnmh nnfolder nnml jcl-master jcl-calendar-init jcl-emms-init
emms-cache emms-info-ogginfo emms-info-mp3info emms-player-vlc
emms-player-mplayer jcl-emms emms-mode-line emms-librefm-stream
emms-librefm-scrobbler emms-playing-time emms-info later-do
emms-playlist-mode emms-source-playlist xml emms-setup emms-lyrics
emms-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf emms-source-file locate emms-player-simple emms
emms-compat jcl-gnus-init jcl-gnus jcl-w3m-init jcl-term ange-ftp
w3m-search w3m-bookmark w3m-antenna w3m-rss jcl-org-import-icalendar
jcl-status jcl-buffer-init org-location-google-maps org-agenda
google-maps google-maps-static url-util url-parse url-vars
google-maps-geocode google-maps-base json org org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities org-version
ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys
ob-comint ob-core ob-eval org-compat org-macs org-loaddefs autorevert
filenotify appt jcl-calendar jcl-swedish-postfix quail help-mode
holidays hol-loaddefs icalendar diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs w3m doc-view jka-compr image-mode timezone
w3m-hist w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl w3m-favicon w3m-image
w3m-proc w3m-util dired-x gnus-agent gnus-srvr gnus-score score-mode
nnvirtual nntp gnus-cache gnus-msg gnus-art mm-uu mml2015 mm-view
mml-smime smime dig gnus-sum nnoo gnus-group gnus-undo nnmail
mail-source gnus-start gnus-spec gnus-int gnus-range gnus-win mailcap
starttls smtpmail auth-source password-cache sendmail message
format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus
gnus-ems nnheader gnus-util mail-utils mm-util mail-prsvr wid-edit
jcl-boot jcl-slime-init slime-fancy slime-trace-dialog
slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree slime-scratch slime-presentations bridge
slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-autodoc eldoc jcl-misc jcl-ert ispell find-lisp jcl-misc-lexical
winner jcl-windows jcl-buffer ido ert find-func ewoc debug jcl-compile
slime-editing-commands slime-repl slime-parse slime compile etags
arc-mode archive-mode noutline outline easy-mmode pp comint ansi-color
hyperspec thingatpt browse-url jcl-face hi-lock dired paren mic-paren
which-func imenu hl-line jcl-times-init jcl-early-init jcl-compat-init
advice jcl-util subr-x jcl-times server term disp-table ehelp ring
sh-script smie executable jcl-load-path tex-site debbugs-autoloads
eimp-autoloads gitconfig-mode-autoloads gitignore-mode-autoloads
gnugo-autoloads ascii-art-to-unicode-autoloads gnuplot-mode-autoloads
edmacro kmacro htmlize-autoloads ipython-autoloads list-utils-autoloads
help-fns cl-macs cl gv cl-loaddefs cl-lib macrostep-autoloads
git-commit-mode-autoloads eieio byte-opt bytecomp byte-compile cconv
eieio-core memory-usage-autoloads finder-inf mic-paren-autoloads
muse-autoloads num3-mode-autoloads python-autoloads
simple-httpd-autoloads info easymenu slime-autoloads svg-clock-autoloads
s-autoloads xml-rpc-autoloads yaoddmuse-autoloads package epg-config
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-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 nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind gfilenotify dynamic-setting
system-font-setting font-render-setting x-toolkit x multi-tty emacs)

Memory information:
((conses 16 1897315 204662)
 (symbols 48 96596 0)
 (miscs 40 3444 7228)
 (strings 32 358637 71705)
 (string-bytes 1 10171033)
 (vectors 16 101602)
 (vector-slots 8 2431265 142560)
 (floats 8 1248 1908)
 (intervals 56 177422 1226)
 (buffers 960 204)
 (heap 1024 137396 27193))