Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use dot instead of face for indentation guides ? #16

Open
lxsameer opened this issue Mar 21, 2014 · 23 comments
Open

Is it possible to use dot instead of face for indentation guides ? #16

lxsameer opened this issue Mar 21, 2014 · 23 comments

Comments

@lxsameer
Copy link

Is it possible to use dot instead of face for indentation guides ? or a character like middle dot ? for example something like this:

class Sample
.    def method1
.    .    puts "hey"
.    end
@ahmadseleem
Copy link

If possible I am in :)

@letronje
Copy link

+1

@vlcek
Copy link

vlcek commented Jul 10, 2014

Hi, here is a quick way how to do that.
I've created a X bitmap image and used it as a value for stipple face attribute.

#define vline_width 7
#define vline_height 4
static unsigned char vline_bits[] = {
0x10, 0x00, 0x00, 0x00 };

There are some problems with pixel width of chars (you have to have same pixel width of xbm image and character or it gets messy). In my case it's 7 pixels. You can check yours with

(frame-char-width (selected-frame))

and adjust the image accordingly.

Here is some elisp for adjusting faces

(set-face-attribute 'highlight-indentation-face nil
                     :stipple (list 7 4 (string 16 0 0 0))
                     :inherit nil)

 (set-face-attribute 'highlight-indentation-current-column-face nil
                     :stipple (list 7 4 (string 16 0 0 0))
                     :inherit nil
                     :foreground "yellow")))

and here is a preview.

highlight-indentation

@kepi
Copy link

kepi commented Jul 10, 2014

looks amazing @vlcek thanks

@bassu
Copy link

bassu commented Aug 16, 2014

@vlcek can you please create a patch?

@stardiviner
Copy link

+1

@Lenbok
Copy link

Lenbok commented Aug 21, 2014

I would be very happy if you could specify both a mark character and a face (kind of like how whitespace-mode does it). Then you could e.g. have a faint '|' character. No worrying about pixel widths since it's a regular character.

@xuhdev
Copy link

xuhdev commented Nov 30, 2014

Fill-Column-Indicator is able to draw a dashed line. Maybe something can be borrowed from there?

@ReneFroger
Copy link

Awesome work, @vlcek !

However, I couldn't figure out how I could create a bitmap image in Paint, with the settings that you deliverd.

#define vline_width 8
#define vline_height 4
static unsigned char vline_bits[] = { 
 0x10, 0x00, 0x00, 0x00 };

Any suggestion?

@stardiviner
Copy link

indent-guide can specify indent line symbol. you can use similar unicode symbols to archive this effect.

@Lenbok
Copy link

Lenbok commented May 31, 2015

@ReneFroger This is what I use in my .emacs which seems to work pretty well for a decent range of font widths (up to char width of 16 pixels). It sets the stipple when enabling highlight-indentation mode on a buffer and looks at the current frame parameters to work out which stipple to set. It can probably be improved to handle an even wider range of widths.

(require 'highlight-indentation)
(defun my-set-highlight-stipple ()
  ;; Define custom stipple for highlight-indentation
  ;; See https://github.com/antonj/Highlight-Indentation-for-Emacs/issues/16
  (let* ((char-width (frame-char-width (selected-frame)))
        (hl-stipple (if (> char-width 8)
                        (list char-width 4 (string 16 0 0 0 0 0 0 0))
                      (list char-width 4 (string 16 0 0 0)))))
    (set-face-attribute 'highlight-indentation-face nil
                        :stipple hl-stipple
                        :inherit nil)
    (set-face-attribute 'highlight-indentation-current-column-face nil
                        :stipple hl-stipple
                        :inherit nil
                        :foreground "yellow"))
  )
;; Patch highlight-indentation-mode to set/update a stipple attribute
(defadvice highlight-indentation-mode (before set-highlight-indentation-stipple activate)
"Sets the stipple used by indentation highlighting"
  (my-set-highlight-stipple))

(edit: included char-width directly in the stipple list).

@ReneFroger
Copy link

Sorry for my belated response, thanks for your reply, I really appreciate it.

I tried your setup, with char-width 7 and char-width 8 without any result. I use Consolas as font by the way, the setting for the font is configured as (set-face-attribute 'default nil :height 110 :family "Consolas").

Any suggestion in order to debug this?

Thanks in advance.

@ReneFroger
Copy link

@Lenbok any chance that your setup is working with Consolas?

@Lenbok
Copy link

Lenbok commented Jun 10, 2015

@ReneFroger Yep, I just installed consolas (nice font!) and:

consolas-indentation

@sangm
Copy link

sangm commented Jun 22, 2015

This is what I get, any ideas? @Lenbok

image

@geraldus
Copy link

Hey folks, is it possible to use a unicode glyph rather than bitmap, for example , , , ? I haven't got used with overlays (yet).

@bassu
Copy link

bassu commented Jul 11, 2015

@geraldus Probably not. But see indent-guide mode. It also works with tabs.

@geraldus
Copy link

@bassu you've made my day! Many thanks!

@zhro
Copy link

zhro commented Aug 26, 2015

I would also like to see the ability to use a Unicode glyph as I typically run emacs in terminal mode.

@tam5
Copy link

tam5 commented Apr 22, 2018

@Lenbok your snippet looks promising, but when i paste it into my .emacs it doesn't seem to have any affect.

Does this still work (Emacs version 27.0.50)

@berendo
Copy link

berendo commented Nov 17, 2018

Does this still work (Emacs version 27.0.50)

It looks like the :stipple face attribute support in Emacs really only works with X11 windowing based builds, not terminal or macOS versions (given it relies on X11 bitmap support).

@JacksonGariety
Copy link

It would be super nice if we could use glyphs for terminal emacs :)

@bfonta
Copy link

bfonta commented May 4, 2022

By slightly modifying the above snippet one can get thin vertical guide lines:

Screenshot from 2022-05-04 14-01-24

(set-face-attribute 'highlight-indentation-face nil
                    :stipple (list (frame-char-width (selected-frame)) 4 (string 16 16 16 16))
                    :inherit nil
		    :foreground "peru")

Information on how :stipple works can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests