I recently upgraded to org from Git. Thus, org-version for me returns:
Org mode version 9.1.6 (release_9.1.6-425-gd89e35 @
In this new version, I discovered that structure templates were not
enabled by default, so I enabled them. But to my chagrin, I found that
I get a "ding" each time I type the TAB key when on a blank line that
is _not_ right after a structure template such as "<e".
Below is my hackaround, but can someone take a look into arranging it
so that is not the default to ding if tempo-complete-tag cannot find
anything to complete, and thus I can remove my hack?
Just passing silent to it will actually break TABing over (normal tab
meaning) in Org buffers, so the obvious fix won't work. (ding)
returns nil which it must so that the hook works as expected.
(defun bg-tempo-complete-tag-no-ding (&optional silent)
;; flet is NOT the same as cl-flet as it does not bind the function _deeply_
;; so that some function that calls the (ding) should pick up this definition
;; here. See https://emacs.stackexchange.com/a/3452/15483
;; The reason we have to do it this way is because if tempo-complete-tag
;; returns t (which it will if we set its 'silent' argument to t), it
;; short-circuits the use of tempo-complete-tag from within
;; org-tab-before-tab-emulation-hook, which means even TABing to the line
;; underneath a Org check-list is broken (doesn't even tab). Ugggggh!
(cl-letf (((symbol-function 'ding)
(lambda (&optional silent)
;; (message "bg-tempo-complete-tag-no-ding: Hack around bug
in ding in tempo-complete-tag or org mode")
(defun bg-org-enable-structure-templates ()
;; Enable Structure templates that at one point were by default enabled in Org
;; mode, but someone changed that for some reason, so re enable it.
;; But tempo-complete-tag is obnoxious. It dings if you have point at the
;; start of a line (e.g., NOT after something like "<e"), and if it cannot
;; find a template prior to point, it dings. So disable that: