Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
4
votes
4
answers
1028
views
Emacs - Changing show-paren-mode Areas
I like show-paren-mode in Emacs, but I would really like to change the highlighting behavior for closing brackets. That is, I want the opening bracket to be highlighted when the point is on the closing bracket. The default behavior highlights the opening bracket when the point is on the character fo...
I like show-paren-mode in Emacs, but I would really like to change the highlighting behavior for closing brackets.
That is, I want the opening bracket to be highlighted when the point is on the closing bracket. The default behavior highlights the opening bracket when the point is on the character following the closing bracket.
Is this easy to change? Also, I would be interested in potential benefits of keeping the show-paren-mode behavior as it is.
user22531
Nov 4, 2013, 07:33 PM
• Last activity: Feb 28, 2024, 04:34 PM
1
votes
1
answers
110
views
Emacs: mode-local macro with dashes and dots
In Emacs, how can I make a macro, that is local to the HTML mode, and uses dashes and dots? Take a look at the Elisp below: (define-abbrev-table 'html-mode-abbrev-table '(("..." "...") ; won't work ("---" "—") ; won't work ("aaa" "...") ; works ("bbb" "—") )) ; works
In Emacs, how can I make a macro, that is local to the HTML mode, and uses dashes and dots? Take a look at the Elisp below:
(define-abbrev-table 'html-mode-abbrev-table
'(("..." "...") ; won't work
("---" "—") ; won't work
("aaa" "...") ; works
("bbb" "—") )) ; works
Emanuel Berg
(7101 rep)
Apr 4, 2013, 01:45 AM
• Last activity: Feb 23, 2017, 08:41 PM
5
votes
2
answers
2208
views
Emacs: mute messages ("echo area")
I do lots of automatizing in Emacs, by stacking commands that I know from using **manually**. That is a method I recommend, because it doesn't take much effort: you use Emacs as you ordinarily would, and now and then it pops to your head, "hey, I'm always using those commands in succession, why don'...
I do lots of automatizing in Emacs, by stacking commands that I know from using **manually**. That is a method I recommend, because it doesn't take much effort: you use Emacs as you ordinarily would, and now and then it pops to your head, "hey, I'm always using those commands in succession, why don't I just merge them?" All the more simple since you know the commands, by name or shortcut.
One problem, though, is that when you stack commands, you get lots of messages flashing by in the "echo area" (same place as the minibuffer). Those messages don't make any sense, as everything going on below (the functions invoked) is (should be) transparent to the user.
So, could you **mute** it, and then **unmute** it? Take a look below:
(defun invisible-pretty-mail ()
"Automatize `pretty-mail'."
(interactive)
; (mute-echo-area)
(rmail-edit-current-message)
(pretty-mail) ; lots of replace-string, replace-regexp, etc. here
; that will flood messages
(rmail-cease-edit)
; (unmute-echo-area)
)
**Edit** in response to sds' [answer](https://unix.stackexchange.com/a/67191/13136) :
I'm very much aware of those notes you refer to, as they are very common in the Emacs help system.
While your advice is not incorrect in general, let us examine this particular situation in greater detail: 1) There is an Elisp function in
.emacs
. 2) It uses commands that the person who setup the function is very familiar with, so it is very readable and maintainable. 3) The function works exactly as intended, with 4) the _one_ drawback that it echos too many messages.
Now, in this situation, would you really suggest a **complete rewrite** of that function (and many others), using altogether different commands, commands that may or may not exist, as a possible way of reducing messages, which we won't even know will happen?
**Edit**: An example (that works), after the help I got from [Drew](https://unix.stackexchange.com/a/83849/13136) .
(defun test-suppress-msgs ()
(interactive)
(let ((log-size message-log-max))
(setq message-log-max nil)
(message "This message is suppressed.")
(setq message-log-max log-size)
(message "This is echoed, and logged.") ))
Emanuel Berg
(7101 rep)
Mar 6, 2013, 10:07 PM
• Last activity: Feb 3, 2017, 09:42 PM
0
votes
1
answers
68
views
Colorful notes in emacs
Similar to org mode, for taking colorful notes in Emacs, I would like to define some special characters (used in the beginning of the lines) to tell Emacs which colors (foreground/background) should be used for highlighting the entire current line. Is there any script for this purpose? If yes, pleas...
Similar to org mode, for taking colorful notes in Emacs, I would like to define some special characters (used in the beginning of the lines) to tell Emacs which colors (foreground/background) should be used for highlighting the entire current line. Is there any script for this purpose? If yes, please let me know how I can use it.
An example of the notes :
# list of operating systems : << highlighted with red
@ Unix << highlighted with blue
@ Linux << highlighted with blue
@ Minix << highlighted with blue
askman
(33 rep)
Apr 19, 2016, 12:54 AM
• Last activity: Apr 19, 2016, 12:42 PM
0
votes
1
answers
699
views
Disable annoying comment highlighting in emacs
I have started programming scheme, and I noticed the scheme minor mode highlights comments in the most obnoxious way possible when using solarized dark (color-theme-solarized). This also occurs on elisp files. Is there a way I can disable highlighting? It's making the code unreadable.
I have started programming scheme, and I noticed the scheme minor mode highlights comments in the most obnoxious way possible when using solarized dark (color-theme-solarized). This also occurs on elisp files.
Is there a way I can disable highlighting? It's making the code unreadable.
Steve
(3 rep)
Nov 18, 2015, 07:41 AM
• Last activity: Nov 18, 2015, 08:20 AM
0
votes
1
answers
59
views
how to write a elisp function like this
I'm trying to write a `elisp` function like this: (setq lst '(("abc" . "c") ("cde" . "f"))) (foo "a" lst) ;=>"c" (foo "b" lst) ;=>"c" (foo "c" lst) ;=>"c" (foo "d" lst) ;=>"f" I know if the first string is same as the key string I can use `assoc`. (setq lst '(("a" . "c") ("d" . "f"))) (cdr (assoc "a...
I'm trying to write a
elisp
function like this:
(setq lst '(("abc" . "c") ("cde" . "f")))
(foo "a" lst) ;=>"c"
(foo "b" lst) ;=>"c"
(foo "c" lst) ;=>"c"
(foo "d" lst) ;=>"f"
I know if the first string is same as the key string I can use assoc
.
(setq lst '(("a" . "c") ("d" . "f")))
(cdr (assoc "a" lst)) ;= "c"
(cdr (assoc "d" lst)) ;= "f"
I could enable the function by writing the lst
separately, but I don't think it's the best way to do.
(setq lst '(("a" . "c") ("b" . "c") ("c" . "c")
("c" . "f") ("d" . "f") ("f" . "f")
))
Can someone help me how to write the function like foo
?
ironsand
(5425 rep)
Nov 10, 2015, 07:02 PM
• Last activity: Nov 10, 2015, 08:17 PM
2
votes
1
answers
1882
views
Color of emacs margins
With the following in my .emacs I get narrow margins in text-mode buffers: (defun my-set-margins () "Set margins in current buffer." (setq left-margin-width 30) (setq right-margin-width 30)) (add-hook 'text-mode-hook 'my-set-margins) How can I change the color of the lines that appear to delimit the...
With the following in my .emacs I get narrow margins in text-mode buffers:
(defun my-set-margins ()
"Set margins in current buffer."
(setq left-margin-width 30)
(setq right-margin-width 30))
(add-hook 'text-mode-hook 'my-set-margins)
How can I change the color of the lines that appear to delimit these margins so that it's the same as my background color and not black like they are now?
**EDIT**
I know more now and this is my question:
How do I add a hook to turn of the fringes in text-mode?

MajorBriggs
(1261 rep)
Aug 6, 2014, 10:50 PM
• Last activity: Aug 7, 2014, 08:29 PM
0
votes
1
answers
159
views
Run emacs elisp command with next word as argument
How can I tell emacs to run my own script (which can be elisp too or something in Perl, BASH or whatever), and use the next word after the mouse cursor as argument, or maybe using a group of marked words? The output would be in another buffer.
How can I tell emacs to run my own script (which can be elisp too or something in Perl, BASH or whatever), and use the next word after the mouse cursor as argument, or maybe using a group of marked words? The output would be in another buffer.
Joseph Will
(1 rep)
Mar 11, 2014, 08:45 PM
• Last activity: Jul 10, 2014, 05:09 PM
3
votes
1
answers
404
views
Hide "Mail" in emacs mode line
This is small stuff but I haven't been able to figure it out: How do I hide "Mail" from the mode line in emacs?
This is small stuff but I haven't been able to figure it out:
How do I hide "Mail" from the mode line in emacs?
MajorBriggs
(1261 rep)
Mar 18, 2014, 02:26 PM
• Last activity: Jul 10, 2014, 04:56 PM
1
votes
1
answers
232
views
emacs change point color to current foreground
I'm trying to customize my emacs so that the point color is the same as the foreground on of the character I'm standing on. I have this now: (defun fixpoint () "awesome stuff happening to point" (interactive) (set-cursor-color (eyedrop-foreground-at-point))) (add-hook 'post-command-hook 'fixpoint) I...
I'm trying to customize my emacs so that the point color is the same as the foreground on of the character I'm standing on.
I have this now:
(defun fixpoint ()
"awesome stuff happening to point"
(interactive)
(set-cursor-color (eyedrop-foreground-at-point)))
(add-hook 'post-command-hook 'fixpoint)
I'm using http://www.emacswiki.org/eyedropper.el for eyedropper.
There are 2 problems with this I'm trying to fix.
First, the hook is ran after each command which seems a bit overkill. Isn't there a hook for point motion?
Second, when highlighting matching braces, the point does not change color. I have to move forward to the next matching brace and jump back to see the actual change in point color.
Silverrocker
(1865 rep)
Mar 27, 2013, 10:41 AM
• Last activity: Sep 27, 2013, 04:28 PM
0
votes
1
answers
1050
views
How do I set key binding for set mark in emacs?
*I'm new to emacs and newer to lisp* I'm trying to set Meta + spacebar to set the mark for highlighting text (at current cursor position). searching around online and experimenting I've ended up with the command (global-set-key (kbd "M-SPC") 'push-mark nil nil 1) The above command isn't working for...
*I'm new to emacs and newer to lisp*
I'm trying to set Meta + spacebar to set the mark for highlighting text (at current cursor position). searching around online and experimenting I've ended up with the command
(global-set-key (kbd "M-SPC") 'push-mark nil nil 1)
The above command isn't working for me though, I'm getting an "incorrect number of arguments error".
Got the function definition,
- push-mark &optional position nomsg activate
- Position: nil for position should default to current cursor position
- nomsg: I don't care about (I think)
- activate: apparently isn't true by default so I need to set it to...something.
- How would I format the command to pass in three values?
-
*The error is definitely due to the push-mark function call as other functions such as backward-char (which I'm not passing inputs to) work correctly*
user1854496
(133 rep)
Sep 22, 2013, 01:03 AM
• Last activity: Sep 22, 2013, 08:29 AM
2
votes
1
answers
207
views
How do I skip special buffers when killing the current buffer?
I have some code in my `.emacs` that prevents it from showing some pre-defined special buffers when I'm using `previous-buffer` and `next-buffer`: (defadvice next-buffer (after avoid-messages-buffer-in-next-buffer) (when (string= "*Messages*" (buffer-name)) (next-buffer)) (when (string= "*Completion...
I have some code in my
.emacs
that prevents it from showing some pre-defined special buffers when I'm using previous-buffer
and next-buffer
:
(defadvice next-buffer (after avoid-messages-buffer-in-next-buffer)
(when (string= "*Messages*" (buffer-name)) (next-buffer))
(when (string= "*Completions*" (buffer-name)) (next-buffer))
(when (string-match "\*tramp.*\*" (buffer-name)) (previous-buffer))
... and so on)
This works great, but I'd like to have the same functionality for C-x k. So far, I've tried writing the same kind of function (defadvice (after kill-buffer) ...)
, but that doesn't seem to work.
How do I go about doing this?
Stefano Palazzo
(598 rep)
Aug 16, 2013, 12:44 PM
• Last activity: Aug 16, 2013, 03:29 PM
3
votes
1
answers
191
views
How to attach elisp function source code in Emacs?
I could use `M-x find-function` to find the source code of some elisp functions if the function is not written in C code. But since I am using a **Debian binary package** of Emacs , some of the source code is omitted and only the byte-compiled `.elc` files preserved. So is there any way to get the s...
I could use
M-x find-function
to find the source code of some elisp functions if the function is not written in C code.
But since I am using a **Debian binary package** of Emacs , some of the source code is omitted and only the byte-compiled .elc
files preserved. So is there any way to get the source code and attach them with those elc files? Can I use apt-get source emacs
and associate with the src (__C code__ as well) with the byte-compiled one. Or do I have to build Emacs from source code?
Hongxu Chen
(5888 rep)
Apr 20, 2013, 03:37 PM
• Last activity: Jun 10, 2013, 06:19 AM
2
votes
0
answers
205
views
Why isn't Gnus scoring emails based on the To: or Cc: headers?
I use Gnus v5.13 in GNU Emacs 24.1.1 to read my email, and I'm having a trouble getting a simple score file to work. Essentially, I want any mail that's sent to (or copies) a particular email address to be given a higher score. My example score file, in `~/Mail/all.SCORE` is: (("from" ("Mark Longair...
I use Gnus v5.13 in GNU Emacs 24.1.1 to read my email, and I'm having a trouble getting a simple score file to work. Essentially, I want any mail that's sent to (or copies) a particular email address to be given a higher score. My example score file, in
~/Mail/all.SCORE
is:
(("from"
("Mark Longair" 1000))
("To"
("mark-scoretesting@example.org" 1000)))
I'm making sure that that score file is being used by having added the following to my ~/.gnus
file:
(setq gnus-global-score-files
'("~/Mail/all.SCORE"))
And this does seem to work properly for the rule that matches the From
line - matching messages are highlighted, and when I type VS in the summary buffer, it shows a score of 1000 for those messages. However, the "To" rule doesn't match. The [documentation here probably explains this when it says](http://www.gnu.org/software/emacs/manual/html_node/gnus/Score-File-Format.html) :
> Scoring can only be performed on these eight headers: From, Subject, References, Message-ID, Xref, Lines, Chars and Date.
[Other documentation](http://www.gnu.org/software/emacs/manual/html_node/gnus/Scoring-On-Other-Headers.html) , however, suggest that one can get around this limitation by the following steps:
> Put the following in your ~/.gnus.el file.
>
(setq gnus-extra-headers '(To Cc Newsgroups Keywords)
nnmail-extra-headers gnus-extra-headers)
> Restart Gnus and rebuild your nnml overview files with the M-x nnml-generate-nov-databases
command. This will take a long time if you have much mail.
>
Now you can score on ‘To’ and ‘Cc’ as “extra headers” like so: I e s p To RET RET.
>
> See? Simple.
Unfortunately, it doesn't seem to be that simple. I've added the following to my .gnus
file:
(setq gnus-extra-headers '(To Cc)
nnmail-extra-headers gnus-extra-headers)
... restarted Emacs, and I've run M-x nnml-generate-nov-databases
, but the rule in my score file for the "To" line, still isn't working, even if I type V R to rescore the articles in my summary buffer.
Can any suggest why this isn't working?
Mark Longair
(121 rep)
Apr 9, 2013, 08:50 AM
1
votes
1
answers
164
views
Emacs function on set of files
Is there a way implemented in Emacs to apply a function on a set of files? (Or, if not, do you know of such an extension?) For example, if you have a project in a directory (say, scripts to compile and run, the source, and an XML database). You want to run this function on all those files, one by on...
Is there a way implemented in Emacs to apply a function on a set of files? (Or, if not, do you know of such an extension?)
For example, if you have a project in a directory (say, scripts to compile and run, the source, and an XML database). You want to run this function on all those files, one by one:
(defun indent-buffer ()
"Indent the whole buffer according to indent-region-function."
(interactive)
(indent-region (point-min) (point-max)) )
What complicates the picture at least to some degree, although certainly not impossible, is that Emacs must be in the correct mode to execute such a function sensibly.
The coolest interface would be to use Emacs as a server, and then send the command, and the file list, as arguments.
Second best if it could be done in Dired.
Emanuel Berg
(7101 rep)
Nov 11, 2012, 10:07 AM
• Last activity: Nov 12, 2012, 11:00 PM
7
votes
1
answers
2696
views
Defining key sequences in Evil-mode Emacs
I couldn't find any instructions on defining key sequences in the Evil doc. The example given by the developers only covers a single key. (define-key evil-normal-state "w" 'foo) What do I need to do, if I want to define "gv" in the normal mode or ";RET" in the insert mode? In Vim, for example, I jus...
I couldn't find any instructions on defining key sequences in the Evil doc.
The example given by the developers only covers a single key.
(define-key evil-normal-state "w" 'foo)
What do I need to do, if I want to define "gv" in the normal mode or ";RET" in the insert mode?
In Vim, for example, I just do:
imap ; ;
map gv :tabprev
Mark T.
(73 rep)
Aug 12, 2012, 02:35 AM
• Last activity: Aug 14, 2012, 10:07 PM
2
votes
1
answers
1421
views
Emacs: query-replace, regular expression, reuse of search result
How do I combine something like `query-replace` with a regular expression search-and-replace that in part reuses the search result? In my case, how to transform > The programmers are "sort of" confident that the subroutines "load_students" and "compute_student_grade" are without bugs. into > The pro...
How do I combine something like
query-replace
with a regular expression search-and-replace that in part reuses the search result?
In my case, how to transform
> The programmers are "sort of" confident that the subroutines "load_students" and "compute_student_grade" are without bugs.
into
> The programmers are "sort of" confident that the subroutines \texttt{load_students} and \texttt{compute_student_grade} are without bugs.
I could use two query-replace
and then hammer yes and no, but it seems sluggish for a big document. Also, I thought about including the whitespace in the searches (one "
and one "
, but that would not work in cases such as ... that's not the way to use "load_students", rather ...
Is there built-in stuff for this or do you write Elisp code?
Emanuel Berg
(7101 rep)
May 29, 2012, 08:08 PM
• Last activity: May 30, 2012, 12:53 AM
2
votes
1
answers
181
views
In terminal, I can search to end of log faster than the data gets there
[The Question] *Is there some way to have the pipe/tee/write combo write lines immediately? ... if it can be done, what is the trade-off?* [The Backdrop] My script sends a keypress to the terminal, which is running `app`. That keypress causes `app` to write a *marker* to its log. The log is the *app...
[The Question]
*Is there some way to have the pipe/tee/write combo write lines immediately? ... if it can be done, what is the trade-off?*
[The Backdrop]
My script sends a keypress to the terminal, which is running
app
.
That keypress causes app
to write a *marker* to its log.
The log is the *app's* normal screen output (timestamped lines).
The log is being written via | tee -a log
The marker *marks* the line I want; ie. the timestamped line *before* the marker.
The problem is that when I then *immediately* search the log (using sed
from the same script), it sometimes returns a previous marker, ie. the most recent marker has not been written to the log yet.
I assume this is a buffering issue, but I'm in unknown territory with that.
Not sure if it matters: The script is elisp
. The terminal is emacs terminal emulator
with a bash
shell.
Peter.O
(33644 rep)
Dec 10, 2011, 03:41 PM
• Last activity: Dec 10, 2011, 04:04 PM
Showing page 1 of 18 total questions