Emacs linum border to wide - emacs

My linum margin is wide (about 6 characters). In most examples on the web, it's not. How can this be changed?
There are no specific parameters set by myself. I am using emacs mac port. There is a custom theme, but it does set anything.

linum-format controls the formatting. If you (setq linum-format 'dynamic) it should adapt the width on the fly. If you want to hardcode the number of columns, you could do, say, (setq linum-format "%5d") for a 5-column number.

Related

Aligning lists in Emacs org-mode with a proportional font?

Does org-mode have a way to correctly align numbered lists (and other indented items) when using a proportional font, like Helvetica?
Thanks!
Not a full fix, but I use the following in my init.el:
;; Ensure the indent face is always fixed pitch. This matches my
;; headline font, and therefore we indent consistent with heading font
;; pitch.
(add-hook 'after-init-hook
(lambda ()
(set-face-attribute 'org-indent nil :inherit 'fixed-pitch)))
This gets the left-hand edge of indents working for me (so they match the indent of headings, for example), but isn't quite right if the bullet/list line is sufficiently long to wrap. Still, it fixes the main problem for me which was these items appearing to be at a higher level than the headings.

How to add padding to emacs -nw linum-mode?

I am using Emacs -nw in Ubuntu. I like to turn on linum-mode to see line numbers on the left margin, but the numbers are put right next to my code.
I would love it if there could be some 'padding', like 1-character long, between line number and code. sorry I can't post an image since they are asking for 10 reputation, which I dont have:(
How can I do this?
You can use the variable linum-format to achieve this. Its value can either be a format string or a function which is called with line number as an argument. emacswiki has a couple of example of setting it to a format string
1) The following adds a space after the line-number
(setq linum-format "%d ")
2) You can also add a solid line separator
(setq linum-format "%4d \u2502 ")
I guess the above are sufficient for your needs. You can also find an example of using a function as linum-format here. Add whichever format suits your needs to your init file
In addition to the other answer(s) in this thread, options for putting distance between the line numbers and the text include, but are not limited to, adjusting the fringe width (and also set the color if you so choose).
The fringe is like a vertical ruler that runs from the top to the bottom of the buffer -- the left fringe is sandwiched between the line numbers and the text. It can be invisible if it is the same color as the default background of the user, or it can be a different color.
(setq-default left-fringe-width 10)
(setq-default right-fringe-width 0)
(set-face-attribute 'fringe nil :background "black")

Border/frame around Emacs frame

How to change the color of some outer or inner border? Whenever I change border-color of the frame, I don't see any changes and it is not allowing me to change the border width.
So far, what did work was
(set-frame-parameter (selected-frame) 'internal-border-width 15)
which adds some frame around the buffer.
But I don't know how to change the inner color. Does anyone know how to have a nice border/frame around the working space?
Any method goes.
EDIT: Added what sds accomplished:
I would like actually to have area around it to have a different color, so outside of the red.
I found an example (read: this is what I was after all along) of a frame I would like to accomplish.
It does appear that you cannot change the border width of an existing frame, but you can create a new frame with the border width you want:
(frame-parameter (make-frame '((border-width . 10))) 'border-width)
==> 10
However, the appearance of the new frame does not differ (as far as I can tell on ubuntu) from that of all the other frames (where border-width is 0);
which, I guess, is not all that surprising given that the window manager may not pay attention to [the border-width] you specify.
The more relevant question, I think, is what are you really trying to do?
Do you want Emacs windows (known as frames in the Emacs world) to differ visually from all the other windows?
If this is what you are after, then you have to realize that window decorations are the domain of the window manager (as mentioned above), and applications (like Emacs) can only affect those using "hints", and window managers are free to ignore them.
However, you can change the parameters of the fringe face:
(set-face-background 'fringe "red")
which should make the Emacs frame appearance very distinct.
I think you are specifying the fringe. You can set the fringe colour with this in your colour-theme function if you are using one.
(defun color-theme-whatever ()
"A color theme"
(color-theme-install
'(color-theme-whatever
((fringe ((t (:background "#111" :foreground "#444"))))))))

How to determine the visible buffer width in characters

I'm using a custom modeline and I'm starting to get how to configure it but here I'm stuck as to how to get the info I want: I'd like to show, in each buffer's modeline, the width in characters of the buffer.
I'm also using linum-mode (with always at least two columns used) and ideally I'd like to deduce the number of characters used by linum from the width.
The function (window-width) is what you're looking for, this doesn't include the characters used by linum-mode however you can get their width from (window-margins)

How can I get Emacs to know that font size has changed when calculating column width?

I'm trying to write a function that does something based on Emacs's current window width. The problem is, Emacs is confused about how wide a column is. It seems to be basing its calculations on the original font size and not my custom set one. Here is a screenshot to illustrate:
It seems to work correctly when I remove my custom font setting, so I think it must be not updating how big it thinks a column is after switching to a new font.
Here's the relevant part of my visual config:
(setq default-frame-alist
'(
(font . "-apple-Ubuntu_Mono-medium-normal-normal-*-17-*-*-*-p-0-iso10646-1")
(width . 130)
(height . 45)))
(obviously the frame was resized from my defaults in the picture, but this is where my font gets set so it seems relevant)
And here's the function I used to determine the computed current width:
(defun get-window-size ()
(interactive)
(message "The width is %d." (window-body-width)))
According to the docs, the window-body-width function should return just the editing area, so any discrepancy between column number and total frame size should be eliminated...
How do I make Emacs update its understanding of column width after changing font?
The "line&column" position indicated is based on the number of characters (tho some characters can count as 2 columns or more, TAB being a common example) rather than based on their visual display size. Different lines can use differently sized fonts, so different lines will reach the right margin at different "columns". In contrast the window sizes are counted in "number of standard-size char-cells" where the size of that standard char-cell depends on the default face (i.e. the font you specified in your default-frame-alist) used for that frame.
In your screenshot, I see nothing that obviously explains the discrepency, tho: you seem to be using a normal monospaced font and all the text uses the same font, and you don't seem to be using something like text-scale-increase, so I'm not sure exactly why you're seeing what you're seeing.