I was trying to achieve the same effect, and based on this email thread, this isn't generally achievable, unfortunately.
I believe the closest we can get to this behavior is manually copying the attributes of the face we want to inherit from instead of actually using :inherit
. This allows the face to merge with other faces properly, but doesn't hold up if you change themes.
If you want to change themes, you'd probably have to keep track of which faces you "disinherited," reset them before loading a new theme, and re-disinherit them after loading the theme.
I haven't implemented that last part, but here's a function that copies over the attributes from the parent face before removing the parent:
(defun disinherit-face (face &optional frame)
"Make FACE non-inherited on FRAME without changing its appearance.
Sets each of the face's unspecified attributes to the the
corresponding value from the face specified in its `:inherit'
attribute, and sets its `:inherit' attribute to nil.
If FRAME is provided, read and set FACE's attributes for that frame.
If FRAME is t, read and set the defaults for face FACE for new frames.
If FRAME is nil, read attributes from the selected frame
and set them for all frames (including the defaults for new frames)."
(let ((face-attrs (delq :inherit
(mapcar 'car face-attribute-name-alist)))
(args '(:inherit nil)))
(dolist (attr face-attrs args)
(push (face-attribute face attr frame t) args)
(push attr args))
(apply 'set-face-attribute face frame args)))
;; This code may be used under the GNU General Public License version 3
;; or later, or CC-BY-SA 4.0.
helm-match
). That's what face customization is for. Show all the attributes in Customize, and uncheck the inheritance.Inherit
checked and check whatever other attributes you want to override any from the inherited face. The point is to use Customize (customize-face
).