0

So I've recently started using gud's M-x gdb instead of gdb on it's own, as it provides Emacs with some nice IDE features, mainly being able to see where you are in the code, and where you have set breakpoints.

Emacs will place an image to the left of a line if a breakpoint has been set there, as seen here: example of GUD's Breakpoint Icons

What I would like to do is change that image, so that it's no longer a red circle and instead something a bit less... ugly...

I did some digging into the code, and found what I think is where the icons are set/handled. In lisp/progmodes/gdb-mi.el, we have the following blocks:

(defconst breakpoint-xpm-data
  "/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
\"10 10 2 1\",
\"  c red\",
\"+ c None\",
/* pixels */
\"+++    +++\",
\"++      ++\",
\"+        +\",
\"          \",
\"          \",
\"          \",
\"          \",
\"+        +\",
\"++      ++\",
\"+++    +++\",
};"
  "XPM data used for breakpoint icon.")

(defconst breakpoint-enabled-pbm-data
  "P1
10 10\",
0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 1 1 1 1 1 1 0 0 0
0 0 1 1 1 1 1 1 1 1 0 0
0 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 0
0 0 1 1 1 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 1 0 0 0
0 0 0 0 1 1 1 1 0 0 0 0"
  "PBM data used for enabled breakpoint icon.")

(defconst breakpoint-disabled-pbm-data
  "P1
10 10\",
0 0 1 0 1 0 1 0 0 0
0 1 0 1 0 1 0 1 0 0
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 0 0 1 0 1 0 1 0 0"
  "PBM data used for disabled breakpoint icon.")

Which I believe are the variable I want to change. However, these are in the Emacs sources and are declared with defconst, so what could I put in my init.el to be able to change these and have my icons look a bit nicer? Or at least be able to change their color.

0

I have found the answer!

Just below that code block, there are a couple declarations for you to use if you want to set your own icons:

(defvar breakpoint-enabled-icon nil
  "Icon for enabled breakpoint in display margin.")

(defvar breakpoint-disabled-icon nil
  "Icon for disabled breakpoint in display margin.")

Using these, you can set the icons for enabled and disabled breakpoints to whatever you want. For example:

(setq breakpoint-enabled-icon
      '(image :type xpm
              :ascent 100
              :pointer hand
              :data
              "/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
\"10 10 2 1\",
\"  c #D78787\",
\"+ c None\",
/* pixels */
\"+++    +++\",
\"++      ++\",
\"+        +\",
\"          \",
\"          \",
\"          \",
\"          \",
\"+        +\",
\"++      ++\",
\"+++    +++\",
};"))

This'll keep the icon the same shape, but instead of the bright red it's a more toned down red. enter image description here

You could also change the icon's shape. For example, if you want a cross in the middle of your circle, you could do something like this:

(setq breakpoint-enabled-icon
      '(image :type xpm
              :ascent 100
              :pointer hand
              :data
              "/* XPM */
static char *magick[] = {
/* columns rows colors chars-per-pixel */
\"10 10 2 1\",
\"  c #D78787\",
\"+ c None\",
/* pixels */
\"+++ ++ +++\",
\"++  ++  ++\",
\"+   ++   +\",
\"    ++    \",
\"++++++++++\",
\"++++++++++\",
\"    ++    \",
\"+   ++   +\",
\"++  ++  ++\",
\"+++ ++ +++\",
};"))

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.