Subject: bug#25125: 25.1; copyright-fix-years pollutes undo history

From: Lluís Vilanova <[email-masked]>
Date: Tue, 06 Dec 2016 20:00:58 +0100

I have setup `copyright-update' to run every time I save a file in prog-mode:

  (add-hook 'prog-mode-hook
            (lambda ()
              (add-hook 'before-save-hook
                        (lambda ()
                            (save-excursion (copyright-fix-years))))))

Every time it runs in a file that has a copyright, a change is recorded into the
undo history, even if the function performed no changes at all (i.e., the
copyright years were already correct).

This makes it quite annoying to go back my modifications history, since it keeps
jumping up and down between the header and the actual code.

Thanks,
  Lluis

In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1)
 of 2016-10-24, modified by Debian built on trouble
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Debian GNU/Linux testing (stretch)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 --with-xwidgets 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs25-25.1+1=. -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
 LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XWIDGETS

Important settings:
  value of $LANG: ca_ES.UTF-8
  locale-coding-system: utf-8

Major mode: Fundamental

Minor modes in effect:
  ogc:--org-gnome-calendar-mode: t
  global-org-gnome-calendar-mode: t
  volatile-highlights-mode: t
  change-cursor-mode: t
  which-key-mode: t
  global-flycheck-mode: t
  global-semantic-mru-bookmark-mode: t
  global-semanticdb-minor-mode: t
  global-semantic-idle-breadcrumbs-mode: t
  global-semantic-idle-scheduler-mode: t
  global-semantic-idle-local-symbol-highlight-mode: t
  global-semantic-decoration-mode: t
  global-semantic-highlight-func-mode: t
  semantic-mode: t
  global-ede-mode: t
  Info-breadcrumbs-in-mode-line-mode: t
  savehist-mode: t
  desktop-save-mode: t
  flx-ido-mode: t
  ido-ubiquitous-mode: t
  ido-everywhere: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-hungry-delete-mode: t
  hungry-delete-mode: t
  global-auto-revert-mode: t
  global-anzu-mode: t
  anzu-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  cua-mode: t
  delete-selection-mode: t
  winner-mode: t
  display-time-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-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
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Loading /home/lluis/.config/emacs/loaddefs.el (source)...done
ad-handle-definition: ‘ido-completing-read’ got redefined
Key Chord mode on
ad-handle-definition: ‘ido-completing-read’ got redefined
ad-handle-definition: ‘Info-read-node-name’ got redefined
Loading /home/lluis/.config/emacs/custom.el (source)...done
No desktop file.
Starting Emacs daemon.
When done with this frame, type C-x 5 0
Turned ON changing cursor when Emacs is idle.

Load-path shadows:
/home/lluis/.cache/emacs/elpa/diminish-20151215.915/diminish hides /usr/share/emacs25/site-lisp/emacs-goodies-el/diminish
/home/lluis/.cache/emacs/elpa/dedicated-20090428.1231/dedicated hides /usr/share/emacs25/site-lisp/emacs-goodies-el/dedicated
/usr/share/emacs/25.1/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/home/lluis/.config/emacs/loaddefs hides /usr/share/emacs/25.1/lisp/loaddefs
/home/lluis/.config/emacs/custom hides /usr/share/emacs/25.1/lisp/custom
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/25.1/lisp/textmodes/rst
/usr/share/emacs25/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/25.1/lisp/language/thai-word

Features:
(shadow sort auto-dictionary mail-extr gnus-msg gnus-art mm-uu mml2015 mm-view
mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo gnus-start gnus-cloud
nnimap nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec
gnus-int gnus-range gnus-win org-gnome-calendar dbus hl-line+ hl-line etags xref
project volatile-highlights ace-link avy xml emacsbug message rfc822 mml mml-sec
password-cache epg mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
minibuffer-complete-cycle smex cursor-chg smart-mode-line rich-minority
which-key server flycheck derived json map compile let-alist my-personal
my-bindings hydra lv my-mail bbdb timezone my-org ob-screen ob-R ob-python
ob-perl ob-octave ob-latex ob-gnuplot ob-dot ob-ditaa ob-C cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
my-programming macrostep jinja2-mode rx smartparens-html sgml-mode disaster
x86-lookup doc-view jka-compr image-mode ede/generic ede/shell ede/config
eieio-opt semantic/sb semantic/sort inversion semantic/db-global
semantic/symref/global semantic/symref semantic/db-find semantic/db-ref
cedet-global semantic/mru-bookmark semantic/db-mode semantic/db semantic/idle
semantic/format semantic/ctxt semantic/decorate/mode semantic/tag-ls
semantic/find semantic/decorate pulse semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local my-writing my-writing-latex
flyspell ispell my-ide ede/speedbar ede/files ede ede/detect ede/base ede/auto
ede/source eieio-base eieio-speedbar speedbar sb-image ezimage dframe
eieio-custom eieio eieio-core cedet my-behaviour info+ ediff-merg ediff-wind
ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff fuzzy dired-filter
f s ucs-normalize dired-hacks-utils dired-aux dired-x savehist desktop frameset
time-stamp browse-kill-ring flx-ido flx ido-ubiquitous ido-completing-read+
cus-edit cus-start cus-load ido key-chord gnus gnus-ems nnheader gnus-util
mail-utils mm-util help-fns mail-prsvr wid-edit org org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities noutline outline
org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src
ob-keys ob-comint comint ansi-color ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs undo-tree diff
hungry-delete autorevert filenotify whitespace anzu saveplace smartparens-config
smartparens thingatpt dash cua-base delsel winner ring my-appearance
smart-mode-line-powerline-theme powerline powerline-separators color
powerline-themes time time-date my-theme my-cmdline my-misc use-package diminish
bind-key my-package finder-inf tex-site edmacro kmacro cl-macs advice info
.loaddefs el-get el-get-autoloading el-get-list-packages el-get-dependencies
el-get-build el-get-status pp el-get-methods el-get-fossil el-get-svn
el-get-pacman el-get-github-zip el-get-github-tar el-get-http-zip
el-get-http-tar el-get-hg el-get-go el-get-git-svn el-get-fink el-get-emacswiki
el-get-http el-get-notify el-get-emacsmirror el-get-github el-get-git
el-get-elpa package epg-config seq byte-opt el-get-darcs el-get-cvs el-get-bzr
el-get-brew el-get-builtin el-get-apt-get el-get-recipes el-get-byte-compile
subr-x el-get-custom cl-seq el-get-core autoload lisp-mnt bytecomp byte-compile
cl-extra help-mode easymenu cconv cl gv cl-loaddefs pcase cl-lib dired debian-el
debian-el-loaddefs emacs-goodies-el emacs-goodies-custom emacs-goodies-loaddefs
easy-mmode dpkg-dev-el dpkg-dev-el-loaddefs bbdb-autoloads mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded 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 dbusbind
inotify dynamic-setting system-font-setting font-render-setting xwidget-internal
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 710117 21824)
 (symbols 48 56785 1)
 (miscs 40 263 397)
 (strings 32 130796 30435)
 (string-bytes 1 4255482)
 (vectors 16 104905)
 (vector-slots 8 2297990 14682)
 (floats 8 11084 1268)
 (intervals 56 563 130)
 (buffers 976 101))