texts: Tabify: How does Emacs decides where to place tabs?

texts: I understand how Emacs can remove tabs when using the untabify command (simply place a number of spaces in the place of the tabs) but what I can't understand is how does it place tabs in the place of spaces? When you use tabify how does Emacs knows where to place tabs? At first I thought that if there were 4 spaces (or a particular number) then it would change them with one tab but clearly that is not the case (as I saw using whitespace-mode). Clearly it is logical that this doesn't happen but if that is not the case then how does Emacs decides where should tabs be?


texts:
I found this today by chance: I visited the help file on split-string with C-h f split-strings:

  split-string is a compiled Lisp function in ‘subr.el’.

  (split-string STRING &optional SEPARATORS OMIT-NULLS TRIM)

except that subr.el is underlined like a hyperlink and doing RET with point on it opens the source code.

I copied it this section to a Markdown file and the text was still underlined. I did RET with point on it and it also opened the source code!

I have these modes active in the document: [(Markdown ElDoc Wrap Fill)]. If I type the same characters as in ‘subr.el’ (copy-pasting the quotes, which I don't have in my keyboard), it is not highlighted and RET does not follow the link.

Including hyperlinks like this one in Markdown is the one thing where I see org mode as superior to markdown mode.

Is it possible to add my own links to other files in markdown mode?

Update: The ability to follow the link with RET is lost when killing and yanking the text that contains ‘subr.el’., or closing and opening the buffer for the file, so I believe this is some special ability in Emacs that comes from copying text from a documentation file and not a feature of Markdown mode.


texts:
I would like to execute a python code block to produce new headlines (i.e. modify the current org file programmatically). If I produce raw results with a replace argument, the replace argument seems to be inactive in this case. For example, if I run 3 times the following code block:
#+name: test_block
#+begin_src python :results output raw replace
print("* Test")
#+end_src

the obtained result is:
#+RESULTS: test_block
* Test
* Test
* Test

And I would expect only one * Test line with the replace argument. The code works as expected if I remove the raw argument (but there is a :  before the headline (* test) which is not a headline anymore).


texts: Terminfo does not export the up arrow resource

texts: When I use TRAMP and a remote shell, terminfo doesn't export the kcuu1 (up arrow) resource. How can I get Emacs to provide this?


texts:
I start my python files (.py) with

#!/usr/bin/env python3

and sometimes

if __name__ == '__main__':
    somefunc()

having done it some hundreds of time manually I decided to automate it in Emacs.

(eval-after-load 'autoinsert
  '(define-auto-insert
     '("\\.\\py\\'" . "python skeleton")
     '(""
       "#!/usr/bin/env python3" \n
       "# ")))

I thought that putting the above snippet in the .emacs file
would be enough.
A new .py file is still empty.

I temporarily removed all Elpy related setups from my .emacs file
having proved (I guess) that Elpy doesn't contribute to the problem.

Using Emacs 24.5.1, Python 3.5.3, Debian 4.9.130-2, Elpy 1.28.0


texts: How to control newline and indent when export to LaTeX from org-mode file?

texts:
I have a test org-mode file as below:

#+OPTIONS: ':nil *:t -:nil ::nil <:nil H:3 \n:nil ^:{} arch:headline
#+OPTIONS: author:nil c:nil creator:nil d:(not "LOGBOOK") date:t e:t
#+OPTIONS: email:nil f:t inline:t num:t p:nil pri:nil prop:nil stat:t
#+OPTIONS: tags:t tasks:t tex:t timestamp:t title:t toc:t todo:t |:t
#+LANGUAGE: en
#+SELECT_TAGS: export
#+EXCLUDE_TAGS: noexport
#+CREATOR: Emacs 25.0.50.1 (Org mode 8.3.1)

* Indent and Newline Test

  First line.

  Second line.

When I export it to pdf with `C-c C-e l p', it generate a pdf file looks like this:

First line.
    Second line.

But what I expect is not indent on the second line and a newline between these two lines.

First line.

Second line.

Would anyone show me how could I achieve that?

Ugly solution:

After read the post mentioned by @wvxvw , I temporarily get a `very ugly' solution for it.

I have to code my content in LaTeX syntax as below:

First line.
\\
\\
Second line.

Then it exports as what I expected. (But the org file looks really ugly)


texts: Is there a command (and ideally a key binding) to navigate to the top (or bottom) of an org table?

texts:
I have read Built-in Table Editor, and searched apropos-function org table for top, bottom, beginning, and end. I found org-table-beginning-of-field, but not anything like org-table-beginning-of-table.
M-{ is bound to org-backward-element, so inside a table it doesn't go back a paragraph but just a line.
C-M-a is still bound in org-mode to beginning-of-defun, which inside a table just goes up one line.
Is there some standard text-mode key binding that gets you to the top of the table that I haven't thought of trying yet? There must already be a way to do this?


texts:
I am searching in a buffer for a regular expression by this snippet:

(setq jb-revision-version "\\([[:digit:]]+\\.?\\)")
(setq jb-revision-string "\\(\\(Revision\\|Id\\): +\\)")
(progn
  (save-excursion
    (goto-char (point-min))
    (setq start (re-search-forward jb-revision-string)
      end (re-search-forward (concat jb-revision-version "+")))
    (setq version (buffer-substring start end))))

The result in variable version is this:

version
#("0.1.2" 0 5 (face font-lock-comment-face fontified nil))

What I want, is the pure string "0.1.2" in this case.

Even if I insert (font-lock-mode -1) ... (font-lock-mode 1) in my above code, the result still contains some font-lock-info:

#("0.1.2" 0 5 (fontified nil))

I haven't found any font-lock-to-string function, to get rid of that stuff.  Neither did I find a command, to temporarily defontify the buffer before searching.

I haven't found any hints in the Emacs, Emacs-Lisp or the Lisp-Introduction Info manuals.


texts: I accidentally set a letter key to another command. How can I reset it?

texts: In the past when this happened, I was able to google the answer with no problem, but this time nothing's coming up.


texts: Why use the "and" in (funcall (and initial-major-mode))?

texts:
I came across this code today, and do not understand why the author used the "and" in it. As far as I can tell, these two lines deliver the same results and have the same functionality. The variable initial-major-mode is defined in startup.el, and holds the value of the initial major mode (lisp-interaction-mode for the scratch buffer).

(funcall (and initial-major-mode))
(funcall initial-major-mode)

Am I missing some nuance why the "and" is useful or required in the code? The only thing I can think of is that it might be an easy way of protecting against a (funcall nil) error if the initial-major-mode is undefined. But since it's a system variable, I would guess that it is always defined?


texts: org-babel's matlab (session) output is malformed

texts:
I'm trying to evaluate some Matlab code using org-babel in a session:

#+BEGIN_SRC matlab :session :results output
a = 1:10;
b = a + 3
c = a - 3
#+END_SRC

And following the org-babel documentation, this is the output I expect:

  b =

      4    5    6    7    8    9   10   11   12   13
  c =

    -2  -1   0   1   2   3   4   5   6   7

But this is the output I get:

  #+begin_example
  a = 1:10;
  b = a + 3

  b =

       4     5     6     7     8     9    10    11    12    13
  c = a - 3

  c =

      -2    -1     0     1     2     3     4     5     6     7
  'org_babel_eoe'

  ans =

      'org_babel_eoe'
  #+end_example

(Including the #+begin_example etc)

After going through the source of the function org-babel calls, it looks like here is what's supposed to happen:

org-babel-octave-evaluate-session copies the code into the Matlab REPL (calling matlab-shell if necessary) and the shell runs it.
It then copies the result back as a string up to the end-of-evaluation token, and then removes the original code from the output string.

it looks like org-babel-octave-evaluate-session is not reading the end-of-evaluation token ('org_babel_eoe') correctly, and not removing the input code from the resulting string either. This looks like it should be an easy fix, but I couldn't figure it out. The relevant function(s) are in /usr/share/emacs/27.0.90/lisp/org/ob-octave.el or equivalent location. I am using Emacs 27.0.90.

Any ideas how to fix this?

Notes:

The same org-babel module pulls double duty for Octave and Matlab with a flag to distinguish between uses, hence the name. When I run the same test as an Octave source block it runs correctly.
This issue regards evaluation of source blocks with the :results output option, where org-babel includes in the results block everything that the REPL prints to stdout. (This is different from the default :results value option where only the return value of the block is considered as a result.)


texts: Using pcase to recursively parse nested lists

texts:
So I'm trying to process the following nested list...

(setq *test*
  '("mt" "trello"
    ("b" "board"
     ("l" org-trello-show-board-labels)
     ("d" org-trello-sync-buffer-down)
     ("u" org-trello-sync-buffer-up)
     ("s" "setup"
      ("c" org-trello-create-board-and-install-metadata)
      ("I" org-trello-install-board-metadata)
      ("u" org-trello-update-board-metadata)))
    ("c" "card"
     ("a" org-trello-assign-me)
     ("A" org-trello-unassign-me)
     ("x" org-trello-archive-card)
     ("X" org-trello-archive-cards)
     ("c" "comment"
      ("c" org-trello-add-card-comment)
      ("C" org-trello-delete-card-comment))
     ("k" "kill"
      ("c" org-trello-kill-cards)
      ("e" org-trello-kill-entity)))
    ("d" "from trello"
     ("b" org-trello-sync-buffer-down)
     ("c" org-trello-sync-card-down))
    ("g" org-trello-abort-sync)
    ("h" "help"
     ("k" org-trello-help-describing-bindings)
     ("v" org-trello-version))
    ("j" "jump"
     ("b" org-trello-jump-to-trello-board)
     ("c" org-trello-jump-to-trello-card))
    ("s" "setup"
     ("I" org-trello-install-key-and-token)
     ("c" org-trello-check-setup))
    ("u" "to trello"
     ("b" org-trello-sync-buffer-up)
     ("c" org-trello-sync-card-up))))

Using this recursive function:

(defun *test/pcase-test (prefix &rest tree)
  (pcase tree
    (`(,(and (pred consp) items))
     (pcase items
       (`(,(and (pred stringp) key)
          ,(and (pred stringp) label)
          .
          ,children)
        (push `(,*prefix-func 'org-mode ,(concat "m" prefix key) ,label) *result*)
        (apply #'*test/pcase-test (concat prefix key) children))
       (`(,(and (or (pred stringp) (pred symbolp)) key)
          ,(and (pred symbolp) fn))
        (push `(,*leader-key-func 'org-mode ,(concat prefix key) ',fn) *result*))))
    (_
     (error "Not a valid definition:\n%s" (pp-to-string tree)))))

NB: I usually begin this function by setting *result* as nil, and setting *prefix-func and *leader-key-func to specific function symbols. I plan to use nreverse to process it's final form.

The goal is to transform this nested list into a series of function calls, *prefix-func for nested lists beginning with two string items (while passing the subsequent items, i.e. children, into another recursive function call, and *leader-key-func for two-item lists consisting of a string (or a symbol) followed by a symbol (which could probably be fboundp, but I haven't decided on that yet).

What's mystifying me is that, when I instrument this function and step through it, it run through the (,(and (pred consp) items) once, and then (since it runs the second nested pcase) it will match (,(and (predp stringp) key)..., pushing at least one item into *result*. But when I step through the second round of execution, despite the fact that when I type e and evaluate (consp tree) (which returns t), it doesn't match (,(and (pred consp) items) the second time.

I definitely don't understand what's happening, or even if I'm doing the right thing with pcase (I've gone through this reference, this EmacsWiki entry, and even the original Emacs reference on pattern matching case, which I admit I don't fully grok. I think I'm doing the right thing, but there's a nuance here I'm not fully getting.

I note that if I replace the (_...) with the following code, it works, but I would like it if the function to throw an error if it comes up with a nested list it doesn't understand:

(items
  (dolist (item items)
    (apply #'*test/pcase-test prefix item))))

I know for a fact that the above code will break if item isn't a list, and I would rather that the function I'm using would just signal me early, rather than break further down the line. Plus, this feels like a cop-out, because then I'd just make a pattern-case that matches anything and hack a way out of my predicament, which still means I don't understand how pcase works.

What am I doing wrong? Anyone's insight on this would be greatly appreciated, thank you!


texts:
I'm accustomed to remapping Esc to Tab in Vim. In Spacemacs this can be done with:

(define-key evil-insert-state-map [tab] 'evil-normal-state)
(define-key evil-visual-state-map [tab] 'evil-normal-state)

in dotspacemacs/config in .spacemacs. This leaves me with the option of pressing C-i when Tab is really needed (quite rarely in my case).

However, shells in Spacemacs are also run in vi-mode, and there Tab key is really convenient for completion, obviously.

How can i either

Run shells in emacs-mode
or disable Tab remapping in shells while retaining it elsewhere?

Thanks!


texts: Emacs occasionally using wrong indent in python

texts:
I have a bunch of python files (ie .py files), which I use Emacs to edit. However I keep having the issue where sometimes emacs will indent regions with 8 spaces instead of 4, and I can't figure out why.

For example, sometimes when I define a function and hit return, Emacs will indent the following code by 8 spaces instead of the usual 4, and pressing TAB will only allow me to cycle between 0 indent and 8 spaces. If I manually enter 4 spaces for the first line, then following ones will appear at the same 4-space indentation, but if I then want to say put in a for loop, I will have the same issue again with the following code being indented by 8 spaces relative to the for ...: command.

I can't seem to sort this out by changing anything in my .emacs file (though I have only been using Emacs for a few months so maybe I'm doing something wrong!) - I have tried putting in

(setq tab-width 4)

and

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function #'insert-tab)

which I found from answers to other people's questions, and neither of them have any impact.
It's also an intermittent problem, it doesn't seem to happen for every file.

Hope someone can offer some help! And I apologise if this is a duplicate question, I searched around but couldn't find anyone else with the exact same issue so I don't think it is!


texts:
I have defined the following TODO states in a org-mode file:

#+SEQ_TODO: TODO(t) WAIT(w) | DONE(d)

And I have customized the colors for the TODO states:

Hide Org Todo Keyword Faces:
INS DEL Cons-cell:
            Keyword: TODO
            Face   : Value Menu Color: red
INS DEL Cons-cell:
            Keyword: WAIT
            Face   : Value Menu Color: orange
INS DEL Cons-cell:
            Keyword: DONE
            Face   : Value Menu Color: green
INS

But I would like to customize the colors of the TODO states at the same place, where I have defined them: in the file.

How can this be done?


texts: Two windows split horizontally-> can't split vertically

texts:
emacs 26.1

I split windows-horizontally by split-window-horizontally

Nice.
Now I want to get smt like this:

I try split-window-vertically , but I get this (not correct result):


texts:
I am trying to install ranger in emacs and
added this one to my .emacs file

(require 'ranger.el)
(add-to-list 'load-path "~/.emacs.d/lisp/ranger/")
(load 'ranger')

I get the following error when I open Emacs

File error: Cannot open load file, ranger.el

When I tried to compile the byte code I get the following error

Entering directory `c:/Users/nneel/.emacs.d/lisp/ranger/'
`ranger.el:84:1:Error: Cannot open load file: subr-x`

I am using GNU Emacs 24.3.1.

Now what am I supposed to do to rectify this error?


texts: How to associate a theme to a file extension?

texts:
It is kind of similar to this question How do I automatically load a mode for a specific set of file extensions?

So I am in a situation where, when I want to write in TeX, I want to use 'whiteboard' theme.
Whereas whenever I want to program in C++ or python, I want to use "afternoon" theme.

I kind of expect my init file to look like

(if [file extention is tex] (load-theme 'whiteboard t) (load-theme 'afternoon t))

Is this right?

I am using Emacs 26.3


texts: emacs home made perspective: source + eshell + compilation

texts:
I want such functionality from emacs (gnu 25),
I press key in any buffer with source code,
and instead of one buffer I got 3 buffers on the screen:

source code buffer
------------------
*eshell* | *compilation*

*eshell* should be created if not exists, and if no *compilation* buffer around,
should *scratch* be shown, but should be replaced with *compilation* after first compilation.

I read about sessions, but as I understand it was not I want.
I want this windows split for any source code buffers, not for specific,
that I save in session and restore from session.

How can I achieve, any known extension/package with such functionality?


texts: What org capture hook to use for saving an attachment in mu4e

texts:
I often need to capture a file attachment from mu4e (pdf invoice), which currently involves multiple manual steps:

In mu4e email view buffer
Save attachment to e.g. ~/filename.pdf
Navigate to ~/filename.pdf
Open ~/filename.pdf
With open ~/filename.pdf buffer: Org capture with link to file

I can see some hooks in org-capture[0] but nothing similar to a kind of hook-before-org-capture-starts.
Any ideas where to start?
[0] https://code.orgmode.org/bzg/org-mode/raw/master/lisp/org-capture.el


texts:
I use Spacemacs. I tried to type a command, but I mistyped. Instead of what I intended, a character was inserted that renders as this:

I suppose that is Tux. When I try to copy the character, I get this: .

How did this happen?
Is this behaviour documented anywhere?

I use the official .spacemacs, with little additions. This happened in org-mode, if that matters.


texts: orgmode image export side by side to both latex and html

texts:
In org export, I want to place two images side by side. I want them to be side by side in both LaTeX export and HTML export. In the example below, the first pair works for LaTeX and the second pair for HTML but not both.

#+NAME: a
#+BEGIN_SRC dot :file /tmp/a.png
  digraph {
    1 -> 2;
    2 -> 3;
  }
#+END_SRC

#+NAME: b
#+BEGIN_SRC dot :file /tmp/b.png
  digraph {
    1 -> 3;
    2 -> 3;
  }
#+END_SRC

* LaTeX

#+BEGIN_CENTER
#+ATTR_LATEX: :height 0.4\textwidth :center
#+RESULTS: a
[[file:/tmp/a.png]]
#+ATTR_LATEX: :height 0.4\textwidth :center
#+RESULTS: b
[[file:/tmp/b.png]]
#+END_CENTER

* HTML

#+ATTR_HTML: :align center :height 300
[[/tmp/a.png]]
[[/tmp/b.png]]


texts: Difference between posix-search-forward and search-forward-regexp (need example)

texts:
In emacs lisp, there's the function posix-search-forward http://www.gnu.org/software/emacs/manual/html_node/elisp/POSIX-Regexps.html.

Does anyone have a full example showing its difference from search-forward-regexp?


texts:
I found something that looks like fun:
https://github.com/ober/zone-matrix

A matrix-inspired EMACS screen saver. I need this in my life, but I can't (for the life of me) figure out how to get it to run.

I've placed the files in my ~/.emacs.d/lisp directory, and appended my init.el to include the load-path and settings per example_user_config.el, but I cannot get it to start by executing 'M-x zone'

I'm running Emacs on MSYS2 (which I believe is the bleeding edge for Windows builds nowadays).

EDIT: Solved. I needed tabbar-mode, which I found here:
https://github.com/dholm/tabbar/blob/master/tabbar.el

Now I see the characters scrolling, it makes me happy!


texts:
In the org manual one finds the H option for exporting. It says

H:
Set the number of headline levels for export (org-export-headline-levels). ...

Q: Is there an export option for setting the initial level for export?

I'd like to skip the first level when exporting.


texts:
The regex info material suggests that \\c6 should match digit characters.

In UTF-8 encoded buffers it doesn't; some of the other category letters work as expected (l, |, a).

Shouldn't \\c6* match 456 in test456test? What do I overlook, misunderstand?


texts: Viewing answers in StackExchange for Emacs

texts:
StackExchange for Emacs is exactly what it sounds like.

After authenticating and loading sx-tab-topvoted emacs, I see a buffer of question headings.

  46   3 Are there any advantages to using ~/.emacs.d/init.el instead of ~/.emacs?
         30d ago [init-file]
  37   6 How can I use Emacs to edit questions, answers, and comments here?
         4d ago [major-mode] [integration]
  34   4 What are the practical differences between the various Emacs Package Repositories?
         32d ago [package] [package-repositories]
  ...

That one looks interesting. I move point over the second question and press RET to View question.

Once I do that, I can see the question header, but not the question body or any of the answers.

Full contents of buffer:

How can I use Emacs to edit questions, answers, and comments here?
Author:   daveloyall
Asked on: 12:15 - 21 Oct (edited 14d ago by Malabarba)
Score:    37
Tags:     [major-mode] [integration]
________________________________________________________________________________

Is this a known issue or do I have a problem with my configuration? What can I do to see the full contents?


texts: Emacs flickers when I run certain commands (gif screencast included)

texts:
After I did an overhaul of my .emacs file yesterday (adding/removing packages, organizing, etc.), I'm left with an annoying screen flicker.  It happens when I move the cursor to the edge of the buffer and keep trying to move it in that direction.

For example, below is a video in which I start up Emacs, navigate my cursor to the top of the new scratch buffer (C-p) and then continue pressing C-p.  It does the same thing if I do C-g (cancel command) when there are no commands to be cancelled as well as a number of other commands which don't move the cursor.

Before adding a list of packages / settings from my .emacs file into this post, I thought I'd ask if anyone had experienced similar problems and if there were any quick changes to settings that did the trick.


texts: How can I create multiple defuns by looping through a list?

texts:
I am working on optimizing my emacs config where I can dynamically create interactive functions for all themes I have in a list.

Below is a simplified version of the construct I am trying to make work.

;; List containing names of functions that I want to create
(setq my/defun-list '(zz-abc
                      zz-def
                      zz-ghi))

;; Elisp macro to create an interactive defun whose name
;; is passed as the macro argument
(defmacro my/create-defun (defun-name)
  `(defun ,defun-name ()
     (interactive)
     (let ((fn-name (symbol-name ',defun-name)))
       (message "Testing creation of function %s" fn-name))))

;; Loop to call the above macro for each element in the list
;; DOES *NOT* WORK
(dolist (name my/defun-list)
  (my/create-defun name))

But if I unroll the loop manually, it works:

;; WORKS
(my/create-defun zz-abc)
(my/create-defun zz-def)
(my/create-defun zz-ghi)

But the below does not work where I pass in the symbol names (which is probably what's happening when the loop unrolls by itself). Note the quotes before the macro arguments.

;; DOES *NOT* WORK
(my/create-defun 'zz-abc)
(my/create-defun 'zz-def)
(my/create-defun 'zz-ghi)

Update

Thanks to @wvxvw's help, I finally got this working!

As @wvxvw suggests, I will not be batch-generating defuns for any and every use case. This was a special use case where for a theme named XYZ, I want to generate a defun called load-theme/XYZ that does the job of

Disabling all other themes that might be active
Calling load-theme for XYZ
Doing some more custom stuff related to that theme; I pass in the custom settings for each theme through the my/themes alist.


texts: just todays agenda for just the current buffer

texts:
I would like to make a quick access agenda for today and just for the current buffer.
So my approach looks like this, but it does not work.
(setq org-agenda-custom-commands
   '(
     ("o"                                ;; Key
      "todays agenda for current buffer" ;; Description
      agenda                             ;; Type agenda
      ((org-agenda-files `(,(buffer-file-name)))
       (org-agenda-span 1))              ;; Options
     )))

I found some inspiration here but it does not really work here atm.
I know you can narrow the agenda to current buffer with < but if it is possible I would prefer to use a custom agenda.
An explanation why this approach does not work would be appreciated.


texts: 'C-M--' on Emacs Terminal on OSX fails with "C-M-_ is undefined"

texts: I'm trying to execute C-M-- from Emacs on Terminal (iTerm2) running on OSX, but I keep getting an error saying C-M-_ is undefined. Any ideas how to workaround this?


texts: file-notify-add-watch : get file path string

texts:
I would to do a specific action (create an org-mod link) when a new file appears in a given directory. For that I need to catch the event but also the path of the new file. I managed to use file-notify-add-watch function which is described here and its work very well, but the output is an "event". How to get a string from this event ?

thx


texts: Sending command from bash in shell-mode, and knowing buffer name

texts:
My specific goal is setting 'vc-mode from the $PROMPT1 snippet so that the mode line will show useful VC info in shell-mode.

I can use emacsclient -e '(setq vc-mode "foo")' but that's not quite enough since 'vc-mode needs to be a buffer local variable, and so I will first need to pass the name of the shell-mode buffer into bash somehow.

Is there a known pattern for doing this kind of thing?


texts: Get unique, permanant revision name in vc

texts:
I am writing some Elisp for a package. I was using vc-working-revision to identify the current revision. But it only returns the branch name, not the hash that name points to. Therefore, this information goes out of date quickly (master now is not master 20min from now).

(I was surprised. Branch names have little to do with revisions.)

I would like to (cross vc-system) get a unique identifier for the current head that is not time-sensitive with vc. How can I do this?


texts: No info file for Auctex when installed manually

texts:
I just installed Auctex manually.
Auctex seems to work but there is no Info 'chapter' when I type C-h i m auctex.
There is no .info file in the auctex directory.
So my question is where do I get the file for the integrated documentation an in which directory should I copy the file?
Thank you.


texts: eshell goes to the bottom of the page after executing a command

texts: when I execute a command on eshell the prompt switches to the bottom of the window. I have to C-l a few times to get it back on top. Once again after I execute anything it goes back to the bottom of the window. It is infuriating. How do I make sure the eshell prompt stays on 'top' of the window at all times with the previous commands being hidden above the window. I don't know if 'window' is correct terminology. Please correct me if not.


texts: Would Emacs Manages Files and Writes in HDD in Someway That Would Cause Malfunction in it?

texts:
Noticed here that var partition is constantly returning error in boot process, compelling me to do a fsck frequentily.

Once it has been used to do high-level using, in dired, org, tramp, Bookmarks+ major-modes, DocView, EIMP to write text files, read them, copy, move and with Terminal using too, would Emacs constant using causes some kind of malfunction in the HDD?


texts: make gnus to place inbound emails per folders

texts:
I have a gmail account, and have set up gnus to read my email over IMAP. I'm also subscribed to a few mailing lists, and want them to be placed in individual directories, e.g. ml-openstack, ml-dpdk etc. so that when I open gnus, I have them not in INBOX, but in ml-openstack, ml-dpdk and so forth.

What should I tweak in emacs/gnus configuration to achieve this?
Thanks.


texts: Colouring mail headers by recipient email addr

texts:
I currently use mutt but am trying to switch email to emacs. One of the features I rely heavily on is the ability to see which of my many email addresses a message was sent to in the mail summary pane just by the colour.

All the mail arrives in the same mbox via offlineimap so I would prefer to label it purely on the contents of the to: field. Any ideas on how best to approach this?

Currently I'm experimenting with mu4e but I have not yet committed to it, so switching to another mail package is ok if it can provide a solution to this.


texts: Can Emacs open a serial connection behind tramp?

texts:
Using for example serial-term, or in lisp make-serial-process one can open a serial port within Emacs. But both will fail if the tty is access on a remote computer thought tramp.

Is there any alternative to using a remote Emacs for this?


texts: Get position in a pdf-page by clicking for annoting a pdf with latex

texts:
In https://tex.stackexchange.com/a/85676/4011, it is illustrated of how to annotated a pdf by using the latex package pdfpages, loading the pdf as a background layer and then use tikz nodes to make annotations at coordinates (x,y) (compare here for similar approaches). The problem is that you need to get the coordinates of where you want to make the annotations manually by reading it from a overlayed coordinate system.

How can I use pdf-tools to get the coordinate automatically by just clicking on the place where I want to insert the annotation?


texts:
I've been using emacs to send yahoo mail for years, then I changed my port settings to enable ssl (switch from 587/nil to 465/ssl), and now I can't send mails anymore - not even with the original settings.
current setup is:
(setq smtpmail-multi-accounts
      (quote
       ((yahoo . ("XXXXX@yahoo.gr"
                  "smtp.mail.yahoo.com"
                  587
                  "XXXXX@yahoo.gr"
                  starttls nil nil nil))))

(I've also tried with 587/nil, 587/ssl, 465/ssl with no difference)
when sending mail I only get a
554 Email rejected
221 Service Closing transmission
Failed to send mail via yahoo account
smtpmail-multi-send-it: Mail not sent

error - it doesn't even ask me to enter my password (I tried also putting that to my /.authinfo, but no luck)
smtp trace has something like:
220 smtp.mail.yahoo.com ESMTP ready
250-smtp404.mail.ir2.yahoo.com Hello XXXX [XX.XX.XX.XX])
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 41697280
250 STARTTLS
220 2.0.0 Ready to start TLS
250-smtp404.mail.ir2.yahoo.com Hello XXXXXX [XX.XX.XX.XX])
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 41697280
250 AUTH PLAIN LOGIN XOAUTH2 OAUTHBEARER
MAIL FROM:XXXX@yahoo.gr> SIZE=529
554 Email rejected
QUIT
221 Service Closing transmission
Process smtpmail connection broken by remote peer

(this smpt404 above looks dodgy to me)
any ideas?


texts: Unfold org subtree containing a special keyword

texts:
Consider the following org file:
* Heading 1
** Subheading 1.1
** Subheading 1.2 containing Keyword
bar
*** foo
foo
*** bar
**** foo
** Subheading 1.3
* Heading 2
** Subheading 2.1
** Subheading 2.2
* Heading 3
** Subheading 3.1 containing Keyword
foo
** Subheading 3.2
** Subheading 3.3 containing Keyword

How can I unfold all subheadings containing "Keyword" but leave everything else folded?
Maybe even better would be to unfold the subtree produced by org-occur Keyword since this hides the other irrelevant subtrees completely.
Edit
If I use org-occur for Keyword, it gives me:
* Heading 1
** Subheading 1.2 containing Keyword
* Heading 2
* Heading 3
** Subheading 3.1 containing Keyword
** Subheading 3.3 containing Keyword

But I want:
* Heading 1
** Subheading 1.2 containing Keyword
bar
*** foo
*** bar
* Heading 2
* Heading 3
** Subheading 3.1 containing Keyword
foo
** Subheading 3.3 containing Keyword

or with all levels:
* Heading 1
** Subheading 1.2 containing Keyword
bar
*** foo
foo
*** bar
**** foo
* Heading 2
* Heading 3
** Subheading 3.1 containing Keyword
foo
** Subheading 3.3 containing Keyword


texts: icicles execute action on all candidates

texts:
I generally use icicles to execute a large number of parallel actions.

One thing I find myself doing often is narrowing the number of candidates, and spamming C-<next> to execute an action on all of the matching candidates.

I've been through the docs, and I can't find a more efficient way to do it. Is there a more finger-friendly way to execute an action on all current candidates?


texts: In Spacemacs, how can I conditionally set line-wrapping on only for text files (i.e. in text mode)?

texts:
I want to have Spacemacs wrap around long lines, but only in text files (i.e. text mode), not in programming language files (i.e. program mode).

How could one achieve that? I know that to turn on line-wrapping one could simply include this in the user-config:

(setq toggle-word-wrap)

To turn it on only for text files, I tried:

(add-hook 'text-mode-hook 'toggle-word-wrap)

But it did not work. How could I implement that?


texts: How can I open a specific revision of a file with Magit?

texts:
Is it possible to open a specific revision of a file in Emacs with Magit without changing the current branch?

I have rebased some local changes to a revision where the modified functions were replaced by functionality in a different file.  I would like to open the old revision of my changes in a separate buffer so I can compare the changes side by side.

My current hacky solution has been to run git show <branch pre-rebase>:file > old_file and then open old_file in Emacs.


texts: How can I specify the maximum number of windows

texts: I like to work with two windows split horizontally or vertically. However, when I try to use C-x 4 f (ido-find-file-other-window) when I already have two windows, it will split one of my windows so I have a total of three windows. How can I change this behavior so that no more than two windows should ever be open?


texts:
Let's say the compilation error has some filenames with line number

blah
blah
src/awesomefile1.c:31
src/awesomefile2.c:152
blah
blah

Assume the filename are parsed in the buffer and are links. Now my cursor is at the beginning of the buffer.

I could C-s search awesome and get to where I want. But is there a way with less typing?

How can I move the cursor to the next filename/linked text? All I want to is move cursor there and open the file on that line number.


texts: Set schema automatically after auto-insert

texts: I have auto-insert-mode configured to insert a basic XML file in nxml-mode, but nxml-mode is then still configured to use an empty schema, as if the file was still empty. How can I automatically make nxml-mode use the correct schema corresponding to the template? Set schema automatically in the menus does work, but I want to run this automatically.


texts:
Our project has a large yaml file edited by multiple developers in multiple environments. When I edit the file in emacs, yaml-mode (I assume?) will trim any whitespace lines:

         Value:
           Item: foo
           Count: 10
---------
   Selection:
     All:
     - Item: Name

The hyphens above represent the legal spaces that yaml-mode deletes on save.

I have no strong opinions on the "correct" whitespace here but since my editor is in the minority in the team, I'd like it to be consistent and leave those spaces.

How can I ask or hack yaml mode to do this?


texts:
I am having a problem working with closures. I hope I can explain this clearly. When I try to start a compilation I typically do it like this:

(let ((dir (get-dir))
  (model-root root)
  (default-directory dir)
  (compilation-environment env)
  (compilation-buffer-name-function
   (lambda (mode)
     (format "*%s %s %s*"
             (f-filename model-root)
             (downcase mode)
             (f-filename dir)))))
(compilation-start "some command" 'foo-mode))

But, I want to use a custom function instead of compilation-start. This custom function will add commands to a queue instead of running them right away. However that means I need to capture the dynamically scoped variables from the let binding. This works fine except for when I get the value of compilation-buffer-name-function, it evaluates to a closure like this.

   (closure ((model-root . "/root/path/") (dir . "/some/directory/") t)
       (mode) (format "%s %s %s" (f-filename model-root) (downcase mode) (f-filename dir)))

The problem is, that form is not a valid form for evaluation. It gives me the error let: Symbol’s function definition is void: closure. I am aware the closure is not a real function and that is merely an implementation detail that is exposed to the user.

Here is my code to call compilation-start when the command is ready (this is the code that is giving the error).

  (cl-loop for command in compilation-queued-commands
                   with bindings = (car command)
                   with args = (cdr command)
                   do (eval `(let ,bindings
                                 (apply 'compilation-start ',(-flatten args)))))

This is the code I am using to capture the dynamic variables

(defvar compilation-dynamic-closures '(compilation-buffer-name-function
                                      compilation-environment
                                      default-directory))
(add-to-list 'compilation-queued-commands
                 (list (mapcar (lambda (var)
                                 (list var (symbol-value var)))
                               compilation-dynamic-closures)
                       compilation-args))

So my question is, how can I capture and replay this closure later?


texts: Are local nested functions possible in elisp?

texts:
It it possible to declare functions whose names are only available in the scope of another function, similar to let?

e.g.:

(defun my-fn (x y)
  (let ((my-local-fn (lambda (a b) (message "%S" (- a b)))))
    (my-local-fn x y)
    (my-local-fn y x))


texts:
I have configured helm to hide the minibuffer and show the input in the header line following this instructions.

The relevant code is this:

(defun helm-hide-minibuffer-maybe ()
  (when (with-helm-buffer helm-echo-input-in-header-line)
    (let ((ov (make-overlay (point-min) (point-max) nil nil t)))
      (overlay-put ov 'window (selected-window))
      (overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
                              `(:background ,bg-color :foreground ,bg-color)))
      (setq-local cursor-type nil))))

(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)

I want the cursor-type to be of type 'bar but setting this in the code above just yields an additional cursor with type 'bar in the minibuffer. The cursor in the helm header line is still a 'box. How to solve this?


texts:
I'm doing a new setup so that I can have an init.el on my dropbox as a one stop shop for my configuration. So far so good but I'm stuck on the theme.

When I setup the code using load-path it all works like it should, all the colors and the modeline. My question is how can I do the same but using the use-package approach?

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")

(setq molokai-theme-kit t)
(load-theme 'molokai t)

Is something like this possible?

(use-package molokai-theme
  :ensure t
  :init
  (setq molokai-theme-kit t)
  (load-theme 'molokai t)
  )


texts: Messages dissapear too quickly from echo area

texts:
When using flymake or similar, syntax highlighting messages will appear in the echo area when you move the cursor to the position of the error.

My problem is that it dissapears too quickly. After about half a second, the echo area clears for some reason unknown to me. Is there any way to configure the echo area such that messages do not get cleared?


texts:
Is there a way to detect when a minor mode is turned on. For web-mode, I would like to know when indent-tabs-mode is turned on.

Please note that what I need is to detect this when the user has begun to edit the buffer with indent-tabs-mode turned off and then decides to turn it on.


texts: How to improve autoloading of Magit's git-commit-mode and other minor modes

texts:
Aim

I would like to arrange for Magit's minor mode git-commit-mode to be enabled whenever a relevant Git file (e.g. COMMIT_EDITMSG) is visited, from both within Emacs (e.g. magit-commit) and without (e.g. git commit with environment variables EDITOR set to emacsclient --create-frame --no-wait and ALTERNATE_EDITOR empty).

I would, however, like the loading of git-commit.el to be deferred until such a file is visited, as loading it and its dependencies increases my Emacs startup time by nearly 100% (i.e. an extra ~0.7s).

Background

I have seen major modes usually tackle this problem by autoloading an addition to auto-mode-alist. The single autoloaded entry-point that git-commit.el defines, on the other hand, is the globalised minor mode itself, which modifies find-file-hook instead. This means that there is no way (obvious to me) to enable the mode or read the value of git-commit-filename-regexp without loading the package, its baggage and the kitchen sink.

What I have successfully done until now is add the equivalent of (cons git-commit-filename-regexp #'git-commit-mode) to auto-mode-alist (despite its being a minor mode), where I manually substitute the value of the defconst git-commit-filename-regexp as defined in the package.

Questions

What effects does adding a minor mode entry to auto-mode-alist have compared to adding a major mode? Does it create a (potentially trivial) risk of breaking something, somewhere? Does this only work with git-commit-mode by chance?
Is there a more elegant or idiomatic solution for autoloading git-commit-mode specifically and minor modes generally?
Could git-commit.el be extended in some way to alleviate this issue?

Update

Those interested, see here for the followup discussion and patch on the project's page.


texts: Writing on Emacs: Spell + Grammar + More checking?

texts:
There is something I never found how to manage correctly on Emacs: advance spell checking.
I know that a lot of modes allow spell check (flyspell, hunspell...) but what I really wonder is: is it possible to reach a Microsoft Word spell/grammar checking level in Emacs? And more than that, is it possible to even go further and provide advanced assistance with synonyms or sentences diversity like some software like Antidote could provide?
In all the talks / tutorials about "writing books using Emacs" I saw, nothing was really clear about spell checking :S
Bonus point: what if I write in French?
Edit:
Example of inputs that would be checked/fixed:

This is you're money.
This is they giant octopus.


texts: I am trying to write in org mode and then export to an odt file. But some tables are better edited in libreoffice, can I include an external odt file that contains the table in org mode? Is there any org keyword for libreoffice's master document?


texts: Company-latex-commands doesn't show completion

texts:
I don't know why in an org buffer, where company-math-symbols-latex and company-latex-command backends are added to the backends list and company is activated, the command company-math-symbols-latex doesn't show any completion, eg. after typing \om where at least \omega is a relevant completion.

The command company-complete-common show me some LaTeX's command completion, but no LaTeX's symbols.

How do I get symbols completion ?

That is my org hook foc LaTeX completion :

  (defun my-latex-mode-setup ()
    (setq-local company-backends
        (append '(company-math-symbols-latex company-latex-commands)
            company-backends))
    (local-set-key (kbd "C-z TAB") 'company-math-symbols-latex))
  (add-hook 'org-mode-hook 'my-latex-mode-setup)

Thank you


texts:
My Emacs config lives inside of a .org file from which I tangle source blocks to a .el file. I could evaluate source blocks with C-c C-c

Today I updated to org-mode version 9 from org elpa and now evaluating a source block like

#+BEGIN_SRC emacs-lisp :tangle yes
(setq org-export-coding-system 'utf-8)
#+END_SRC

with C-c C-c prints the following message

  Evaluation of this emacs-lisp code-blockis disabled.

In my init.el I have already defined the languages for org-babel:

(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
  (org . t)
  (sh . t)))

If I load the stock Emacs version of org-mode I can tangle with C-c C-c as expected.
I could not find any changes regarding this in the changelog for org-mode 9.

How to enable evaluation of code-blocks in org-mode 9?


texts: How to subset org headlines by timestamp and tag

texts:
I have just started using emacs-org to index news headlines.

I've adopted the convention: <2018-10-10 Wed> Key Headline :TAG:

Here's a concrete example (with made up headlines).  Say that i'm tracking news about Trump. A collection of headlines may look at below -- i use C-c C-d to insert the timestamp generated by org-deadline-string.

* Trump says China not seeking deal seriously :China:
 DEADLINE: <2018-10-11 Thu>
* Trump says he will meet Kim :NorthKorea:
 DEADLINE: <2018-10-10 Wed>
** Trump says NK is special place
** Trump says Kim a good man
* Trump says China ready to do a trade deal :China:
 DEADLINE: <2018-10-08 Mon>
* Trump says not happy with Kim :NorthKorea:
 DEADLINE: <2018-09-02 Sun>

I wish to query these headlines by tag and timestamp.  Say to see only headlines tagged :China: after 10 October.

How might i do this?


texts: Faces not set immediately after load-theme

texts:
I'm trying to set the faces of highlight-indent-guides automatically whenever a new theme is loaded by making small adjustments to the background color of the default face. I have everything working here, but I've been forced to resort to the following horrible hack:

(defun imalison:set-highlight-indent-guides-faces-load-theme (&rest args)
  (if (face-background 'default)
      (imalison:set-highlight-indent-guides-faces)
    (run-at-time "1 sec" nil 'imalison:set-highlight-indent-guides-faces-load-theme)))

(advice-add 'load-theme
            :after 'imalison:set-highlight-indent-guides-faces-load-theme)

The reason the timer is needed is because (face-background 'default) is nil immediately after the call to load-theme, even though it is properly set a few seconds later. As I mention in the issue that I filed against highlight-indent-guides, I suspect that load-theme might rely on a callback somewhere when setting face values, which would explain why the face is not set when the function returns. Does anyone who is more familiar with emacs' theme system know what is going on here? Is there a reason there is no after-load-theme hook?


texts: emacs tabbar -- how to get tabs for all buffers displayed in one go, regardless of extension?

texts:
I use, and love, tabs, using the following in my .emacs:

(require 'tabbar)
(tabbar-mode 1)
(global-set-key [(control shift iso-lefttab)] 'tabbar-backward-tab)
(global-set-key [(control tab)]       'tabbar-forward-tab)

Since upgrading my distro a few months back (i'm sure it wasn't true before that), i've found that if i load several files with different extensions, then the tabs appear in different groups;  e.g.,

emacs junk1.txt junk4.txx junk2.txt junk3.ttx junk9.txt

gives me one "screen" (if you see what i mean) that has tabs for junk1.txt, junk2.txt, and junk9.txt;  and another with tabs for both junk4.txx and junk3.ttx (and yes, those two do have different extensions).

I can, of course, switch buffers to move between "screens" (and, err, between buffers);  but what i want is to have tabs for ALL my files  visible in a single "screen", so i can tab through all of them.   Any ideas how to achieve that (or for that matter, why i don't currently get that behaviour)?

Fwiw:
GNU Emacs 26.2 (build 1, x86_64-mageia-linux-gnu, GTK+ Version 3.24.7) of 2019-04-12

Thanks,
ian


texts: How can I force display-buffer to use one specific frame?

texts:
My daily workflow uses multiple frames, and I have a frame that I want to dedicate to ERC buffers.  I've used set-frame-parameter to give the frame the name *ERC*.

I want display-buffer to always display ERC buffers (identified by the regex \`#) in this frame named *ERC*.

I've tried the following:

(add-to-list 'display-buffer-alist
     '("\\`#"
       nil
       (inhibit-switch-frame)
       (reusable-frames . "*ERC*")))

But buffers still appear all over the place.  I've also tried replacing *ERC* with \\*ERC\\*.  Help?


texts: Automatically installing the available version of org

texts:
Based on this reply, my code has the following function that installs its dependencies:

(defun literef-install-packages()
  "Install any missing packages. The code is taken from
`https://stackoverflow.com/a/10093312/2725810'."

  (setq package-list '(org org-ref pdf-tools smooth-scrolling company))

                    ; list the repositories containing them
  (setq package-archives '(("elpa" . "http://tromey.com/elpa/")
               ("gnu" . "http://elpa.gnu.org/packages/")
               ("marmalade" . "http://marmalade-repo.org/packages/")
               ("melpa" . "http://melpa.milkbox.net/packages/")))
  (package-initialize)
  (unless package-archive-contents
    (package-refresh-contents))

  (dolist (package package-list)
    (unless (package-installed-p package)
      (when
        (yes-or-no-p (concat
            "The package " (symbol-name package)
            " is not installed. Install it? "))
        (package-install package)
        (when (eq package 'pdf-tools) (pdf-tools-install))))))

The problems is that Emacs comes with built-in org, which makes it impossible to install the version from MELPA by using (package-install 'org), since the package is "already installed". How do I fix my code to work for org as well as it works for the other packages?

I looked through package.el to find a way to get to the list of available packages. The closest I found was the variable package-alist. However, it only contains 20 entries, so it is not what I am looking for.

In addition, I do not know how to technically install a package with a specified version. Namely (package-install 'org) says that the package is already installed, but (package-install 'org-9.1.14) says that such a package is not available, although I do see org version 9.1.14 in the package manager and am able to install it from there.

The other idea is to uninstall the built-in org first so as to be able to use (package-install 'org) to install the latest version. However, I do not know what to supply as an argument to (package-delete).

UPDATE: I have posted my solution here.


texts:
How can I configure Emacs so that it displays CPU and memory usage in the mode line?

The package mode-line-stats does this, but it has not been developed for several years, and it has not been submitted to any online package repository.


texts: Presenting part of the buffer in alternative way with editing capabilities and background recoding/validation?

texts:
Windows .reg files are almost human readable. Because some types require binary encoding, like:
"Name"=hex(2):54,00,65,00,6d,00,70,00,6f,00,72,00,61,00,72,00,79,00,20,00,53,\
  00,65,00,74,00,75,00,70,00,20,00,46,00,69,00,6c,00,65,00,73,00,00,00

There is HEX with commas of UTF16-LE string. What Emacs API and techniques help presenting above string as "Temporary Setup Files", allowing editing specially encoded piece in a human understandable format?
How other API integrates with a solution (like search over original encoded string or "decoded")?
So I want to see above string as:
"name"=hex(2):"Temporary Setup Files"

be able to edit it, add some fancy colors to denote that region was "decoded" and report validity.


texts: fixing python-mode automatic line-breaks in the output?

texts:
I'm using emacs python mode to evaluate python (3.6) code and expressions. The mode (or emacs) seems to automatically break output lines at a certain length, even though my screen is wide enough to hold the whole thing. Below is an example:

>>> dfv
sector       treasury  hardware  theater  telecom  brewery  highways  cars  \
sector
treasury          0.1       0.0        0        0      0.0       0.0   0.0
hardware          0.0      19.0       -2        4      1.0       1.0   1.0
theater           0.0      -2.0       28        1      2.0       1.0   1.0
telecom           0.0       4.0        1       22      0.0       1.0   2.0
brewery           0.0       1.0        2        0      4.0      -1.5  -2.0
highways          0.0       1.0        1        1     -1.5       3.5   2.0
cars              0.0       1.0        1        2     -2.0       2.0   5.0
bank              0.0       0.5        0        0     -1.0       0.5   0.5
software          0.0      10.0       -2        3      1.0       1.0   1.0
electronics       0.0       5.0       -1        4      1.0       1.5   2.5

sector       bank  software  electronics
sector
treasury      0.0       0.0          0.0
hardware      0.5      10.0          5.0
theater       0.0      -2.0         -1.0
telecom       0.0       3.0          4.0
brewery      -1.0       1.0          1.0
highways      0.5       1.0          1.5
cars          0.5       1.0          2.5
bank          1.0       0.5          0.5
software      0.5      25.0          8.0
electronics   0.5       8.0         16.0

Is there a way to let python-mode to use the full window width or turn off the automatic line-break gracefully?

I am using Emacs 25.x GUI, Ubuntu 18.04.


texts: How can I determine the width of characters on the screen?

texts:
Specifically, I'm interested in the width of characters in the default font assuming that the default font is mono-spaced.  From reading the documentation, I got the impression that this should give me the correct value:

(aref (font-info (face-font 'default)) 2)

However, these values are consistently too big.  For example, my current default font is

-unknown-DejaVu Sans Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1

and the code above gives me 13.  However, when I make a screenshot and measure the characters their width is only 8 pixels.  frame-char-widthgives me 8 pixels but if I change the default font size (using text-scale-increase) it continues to say 8, so that isn't useful.

I'm working with Emacs 25.0.50.2 on Ubuntu 14.04.


texts: Map a key to act like a combination of modifiers

texts: I've got a keyboard, where pressing M-C-S is uncomfortable (Meta and control are under the thumbs and Shift is on the far end of the keyboard).  However, PageUp, PageDown, Home and End are in a very comfortable place.  I never use any of those keys though, so I was thinking, if it was possible to remap, say, Home to act like M-C-S, that would make my life a lot easier.  I would be even happier, if the solution wasn't Emacs-only, but on the system level (it is okay if it is Linux-only).


texts: How to make M-x and C-h f share the history?

texts:
It's quite common that I'll look through a command's documentation
with C-h f, and then invoke the command with M-x immediately
afterwards.

Right now, the shortest way I've found to “invoke the last view
command” is to copy its name (either from the help buffer or from the
history) and yank it into M-x's minibuffer prompt.

What I would really like is for command names given to
describe-function to be part of the history of
execute-extended-command. So I could just do M-x M-p RET.

What's the easiest way of doing this?


texts: Reload configuration for a package when using req-package

texts:
I'm using req-package to manage per-package configuration in my init.el. All works fine when in stable state. Let's say I need to modify it. For example, I might want to add a new key mapping. I find the req-package sexp for a particular mode, I add the necessary change to the :config element, restart Emacs and all is good.

My question is, is there a way to do this without restarting Emacs? Basically, I'd like to re-run a particular req-package sexp or in other words reload / reinitialize a particular package.

I know I can run the commands separately, but running the whole req-package does not seem to have any effect, which I presume is because req-package already knows the package was loaded / initialized.


texts:
Magit is unable to commit anything is giving the following message

  1 c:/cygwin64/bin/git.exe … commit -- Waiting for Emacs...

  ERROR: Wrong type argument: arrayp, nilerror: There was a problem with the editor '"c:/Program Files
  (x86)/Emacs/emacs-24.5/bin/emacsclient.exe"'. Please supply the
  message using either -m or -F option.

How do I pass the -m and -F option?

platform - Windows 8
Emacs - 24.5.1
installed magit from package manager.

I wanted to use cygwin with emacs, having set that, cygwin didnt see the windows git properly - hence I installed git for cygwin. Probably that's causing some issue? In my exec-path I have the path of cygwin-git. I am new to magit so help would be appriciated and also let me know if I can provide with more information.

EDIT : Both the git installation work properly - I tried some test commit from and cygwin and cmdprompt and I am able to commit normally.


texts:
I do a lot of R coding on Emacs – on Windows – using the wonderful ESS package. What I particularly like is that I can:

start an R session, and then send lines or regions of the script I'm working on to that session
send the whole script to be evaluated
switch back and forth between R session and script editing

ESS also provides some documentation when inputting an R function (for example which arguments it requires) and some autocompletion features. But these are less important to me than the above three.

Can you suggest an Emacs mode for working with python scripts, similar to ESS in the three points above? (I have an Anaconda Windows installation.)

I've explored elpy, but it's extremely slow (often completely freezes Emacs) and doesn't seem to have the possibility of sending lines to the interpreter.  It has the right functionality but can be too slow in its base configuration. Probably it tries to do too much; for example it gives information about imported packages but frankly I don't need that. No project-management help is needed either.

I've heard of anaconda mode but it doesn't seem to provide interaction with an interpreter: only autocompletion and documentation. I've also heard of python mode but haven't understood if it provides interaction with a python interpreter. Finally, Jedi is a total mystery, and EIN doesn't seem to be designed for scripting.

It seems that with python part of the problem is also the choice of interpreter, if I understood correctly. In this case, which python interpreter would be best, to achieve something similar to the R+ESS seamless interaction?

Most related questions on StackExchange are 4–6 years old; presumably a lot has changed in the meantime.

Thank you all.


texts: How do I make a public reply to a particular post in an Emacs bug report?

texts:
I am looking at the thread of a particular Emacs bug report through the bug-gnu-emacs archives. Suppose I want to make a public reply to one of the posts in the thread. On the web page of the post, I see a button I can use to reply:

If I click on the button, my email client will fill in the post author's personal email address in the "To" email field (e.g. john.smith@example.com). If I actually send the email, will the reply be made public? I want to make a public reply. How can I ensure that I am making a public reply?
I thought that I have to send replies to 123456@debbugs.gnu.org (where 123456 represents the bug report number), so do I need to add 123456@debbugs.gnu.org to the "CC" field or something?


texts:
I've hit a brick wall with this.  I'm running cygwin on a Windows 7 machine.  I can't connect vai ange-ftp to an ftp server, hosted by godaddy.com.  I do C-x C-f /username@ftp.foo.com: (to get a dir listing) or :index.html (file exists), and in both cases emacs asks me for my password, I enter it, and then emacs freezes.  Hard freezes - only way to kill it is to use Task Manager, and kill two emacs-w32 processes.

I'm using the cygwin emacs-w32 program.

My .emacs includes (require 'cygwin-mount).  I also tried (require 'setup-cygwin) (downloaded most recent version today), but that doesn't load properly.  Error about "cannot find cygwin", having to do with a variable that sets the path to cygwin.  I couldn't figure it out so commented out (require 'setup-cygwin).

So - suggestions?  Could this relate to what ftp client emacs / ange-ftp is finding?  Other things about my emacs setup for cygwin?  I've been using cygwin emacs for about 6 months and most other things work, including running processes from within emacs (shell, tex, grep, diff, etc).

Thanks.

Here's the result of emacs-w32 --debug-init with (require 'steup-cygwin) in my .emacs.  Alas I can't give any error info on the actual ange-ftp issue, since emacs just freezes.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-directory-p(nil)
  (and (file-directory-p directory) (file-readable-p directory) directory)
  setcyg-dir-p(nil)
  (if (setcyg-dir-p cygwin-root-directory) nil (error "Cannot find Cygwin.  Please customize option `cygwin-root-directory'"))
  eval-buffer(# nil "/cygdrive/c/Users/strozzi2/.emacs.d/lisp/setup-cygwin.el" nil t)  ; Reading at buffer position 4972
  load-with-code-conversion("/cygdrive/c/Users/strozzi2/.emacs.d/lisp/setup-cygwin.el" "/cygdrive/c/Users/strozzi2/.emacs.d/lisp/setup-cygwin.el" nil t)
  require(setup-cygwin)
  eval-buffer(# nil "/cygdrive/c/Users/strozzi2/.emacs" nil t)  ; Reading at buffer position 1708
  load-with-code-conversion("/cygdrive/c/Users/strozzi2/.emacs" "/cygdrive/c/Users/strozzi2/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262

**** With new setup-cygwin.el from Drew, it behaves as he said.  The relevant part of .emacs is:

(require 'cygwin-mount)
(setq cygwin-root-directory "/c/cygdrive/cygwin64/")
(require 'setup-cygwin)

Startup now works.  C:/cygwin64/ didn't.

And ange-ftp works!  Once I put ftp in passive mode to get around firewall.  Success!


texts:
I want to make Control-i perform indent-region (basically since Xcode has built that muscle memory already).

I realise that Control-i and tab are indistinguishable in the Ascii sense, but they are in the keycode sense.

I've tried the obvious:

(global-unset-key (kbd "C-i"))
(global-set-key (kbd "C-i") 'indent-region)

to no avail - pressing Control-i still just does whatever the tab key does in the current context. Is there anything I can do to help Emacs treat the tab button differently to Control-i?

Update: I guess an equivalent outcome would be achieved by being able to remap what a tab/Control-i press does when a region is selected.


texts: Run command after each type/insert in particular buffer

texts:
I'm implementing a (optional, de-activable) real-time syntax checker. Each time the user types/deletes anything, I want to run my spell-checking funtion :

I tried (add-hook 'post-self-insert-hook 'syntax-check-continuous) but now even when I type in the minibuffer, the function is run.

What would be the good practice for that? An advice after an insert function? An (add-to-list 'before-change-functions 'syntax-check-continuous)?

I'd really like to see existing real-time syntax checker implementations, I don't want to make Emacs behave in a weird way.


texts:
I use org-agenda-todo-ignore-scheduled set to 'future to ignore / not show TODOs in the global todo list that are scheduled in the future.
org-agenda-todo-ignore-scheduled set to 'future seems to work for TODOs that have only a date and not a time.
E.g. if today is Oct 23 2020 at 10 am and a TODO has a timestamp of e.g.:
SCHEDULED: <2020-10-24 Sat .+1d>

then it is not shown.
BUT a TODO with:
SCHEDULED: <2020-10-23 12:00 Fri .+2h>

is shown in the Global todo list even though it is scheduled for 2 hours into the future.
I have been searching for a variable or setting that could make the global todo list also ignore TODOs that are x hours into the future but have not been able to find anything.
Is there any way to do this?


texts:
When I the first time enter an org-mode buffer, I get no font lock at all unless I revert-buffer or reopen the file. Even I turn on the debug mode, no error is emit.

How should I debug and fix this?


texts: Can emacs commands be called from a shell script?

texts: I have a directory ~/foo that contains several org files. I'd like to use htmlize to convert each org file into an html file. Ideally this would be done with a shell script. Is there a way to make a shell script use htmlize to accomplish this?


texts: The export of external links in org files to pdf and html files

texts:
I have a problem with the export of external links in org files to pdf and html files.
Let's say I have the two org files in the same directory:
file1.org =
here is the label of file1:  <>

and file2.org =
go to the label of file1: [[file:./file1.org::label]]

After exporting: Both links of file2.html and file2.pdf don't work.
Both variables org-latex-prefer-user-labels and org-html-prefer-user-labels are t. So the labels are constructed with the correct name (also correct format?):
In file1.html:
here is the label of file1:

In file1.tex:
here is the label of file1:  \label{label}

In file2.html:
go to the label of file1: ./file1.html#MissingReference

The linked file is here correct (file1.html) but the label isn't found.
In file2.tex:
go to the label of file1: \url{./file1.org}

The org file is linked not the pdf file. So  even the linked file is here wrong.
What I've tried is using the CUSTOM_ID as label. This works perfectly with the html export but not with the pdf export. And I prefer the <<..>> labels because they are more flexible.
Any Idea to solve the problem? Should I use another link format?
(Org version: 9.4.4)


texts: How to tell if more than one window is open?

texts:
How do I tell if more than one window is open programmatically? (I am looking for an elisp function/snippet or variable I can check)

(I want to open a REPL in another other window if one exists, otherwise create a new window and open it there.)


texts: Set the major mode of a new buffer interactively

texts:
When creating a new buffer via:

C-x b
NonExistentBufferName RET RET

I would like Emacs to ask me what major mode this buffer is going to use upon opening.
Moreover, I want Emacs to infer the major mode in some cases based on the buffer's name:

C-x b
test.org(no such buffer so far) RET RET
=> org-mode is used without asking me anything.

Could anybody advice if I can use any package for this? Or is it achievable at all via pure elisp?

P.S.
I'm using ido if it matters.


texts: Making Keys Pass Completely Through Emacs

texts:
An Autohotkey remapping script I'm using uses the function keys F13-F24 to keep track of layers. This means that {F13 Down}, for example, may get sent as a virtual key code.

This works fine for most applications. However, Emacs recognizes the function keys and does not pass them through (even though they don't exist on my keyboard and I can't activate them external to Autohotkey). This is causing unwanted behavior when I switch layers.

I can make the "key undefined" messages go away by using

(global-set-key [f13] 'ignore)
(global-set-key [f14] 'ignore)
...

However, Emacs still registers the keys, and they will stop sequences for commands. For example, in Spacemacs one switches windows using Spc 0-9. To access the numbers, I press a key that sends {F13 down}, then press a letter key. Rather than Spacemacs interpreting this as Spc #, a message prints saying that Spc <f13> is undefined. Even though they are nil, Emacs still "recognizes" them.

What I would like to do would be to have Emacs completely ignore the F13-F24 keys. That is, if Emacs receives a keycode corresponding to some key from F13-F24, it doesn't even register it, but ignores it as if it had not been pressed.

I tried using

(define-key input-decode-map (kbd "<f13>") nil)
(define-key input-decode-map (kbd "<f14>") nil)
...

in my config file, but the keys still register. According to my understanding of Translation Keymaps, I thought this would work. I'm at a bit of a loss now as to how I might go about disabling these keys.

Help?

Edit: I have solved the issue on the Autohotkey end of things. Instead of using F13-F24 for keeping track of layers, I'm using unassigned virtual key codes. (See this thread). It's a bit harder to maintain, but there is no interference with Emacs.

I've gone ahead and accepted @Gilles' answer since it mostly worked on the Emacs side of things. There were intermittent problems with auxiliary modes/maps getting activated that I was never able to pinpoint. I seemed to only have problems switching windows with Spc <f13> <letter> = Spc # when I was going from window to window with no keypresses in between. If I pressed Esc every time I arrived at a window before using Spc # to go to a different one, everything worked fine.

I'm pretty new to programming in general and Emacs in particular, so someone more knowledgeable might be able to actually create full pass through on the Emacs side of things. Here's some links that looked like they would be useful if I knew what I was doing:

Keymap priority
Using an overriding minor mode or use-package bind*


texts:
Shown below is a simple function, which was run in the middle of a text file that contained multiple instances of repeated blank lines.  The output of the function is also shown below.

The only difference between my-search-string-1 and my-search-string-2 is the use of ..\n.. in the first string and ..\\n.. in the second.  Since a tab character has to be escaped via ..\\t.., why doesn't the newline character have to be escaped via ..\\n..?

(defun my-find-consecutive-blank-lines ()
    "re-search-forward two or more consecutive blank lines."
    (interactive)
    (setq my-search-string-1 "\\(^\\(\\t\\| \\)*\n\\)\\{2,\\}")
    (setq my-search-string-2 "\\(^\\(\\t\\| \\)*\\n\\)\\{2,\\}")
    (if (re-search-forward my-search-string-1 nil t)
        (print "my-search-string-1 Found")
    ;;else
        (print "my-search-string-1 Not Found"))
    (if (re-search-forward my-search-string-2 nil t)
        (print "my-search-string-2 Found")
    ;;else
        (print "my-search-string-2 Not Found"))
    (makunbound 'my-search-string-1)
    (makunbound 'my-search-string-2))

"my-search-string-1 Found"
"my-search-string-2 Not Found"


texts: How to display *help* buffers below one specific window?

texts:
I am (really) new in Emacs and ESS, and I am currently trying to customize my environment.
The default settings of ESS[R] are convenient for me, since ESS[R] organizes the windows as follows:

-----------------------------
|   ESS[R]    |    *R*      |
|  (R code)   | (R console) |
|             |             |
|             |             |
-----------------------------

But one thing I don't like is that, when you call an help page (or when using the C-c C-v shortcut), the default is to display the help page instead of the R buffer, like that:

-----------------------------
|   ESS[R]    |  *help[R]*  |
|  (R code)   |             |
|             |             |
|             |             |
-----------------------------

I would like the help buffer to be displayed just below the R buffer instead, like that:

-----------------------------
|   ESS[R]    |    *R*      |
|  (R code)   | (R console) |
|             |-------------|
|             |  *help[R]*  |
|             |             |
-----------------------------

But I don't manage to do that. I read carefully the manual, but I should have missed something. I added the following instructions in my .emacs file:

 '(display-buffer-alist
   (quote
    (("*Help"
      (display-buffer-at-bottom)
      (slot . 1)
      (side . right)
      (window-width . 0.5)))))

but it does not work, since the help buffer is displayed below the two other, with a width of 1.
What should I do to get the window organization I want?


texts: When does tramp create a new connection for a process?

texts:
What/where is the logic that determines whether tramp reuses its current connection in order to execute a process or creates a new connection?

Is it as simple as spawning a process synchronously vs async?


texts: How can the start up log of Spacemac be viewed?

texts:
When I start Spacemacs there is a message about some faults on my setup which scroll past quickly before I can view them.

Is there some file or some buffer that holds them for review?


texts: How can I switch a preview image in an `org-mode` buffer to its source block?

texts:
In org-mode, I use preview images for various things such as latex formula and linked images (e.g. [[file:xxx.png]]]). At times, I need to change the code for these and switch back to the code view. I know I can use things
like C-c C-x C-l for LaTeX and M-x org-toggle-link-display.
Is there a simpler way to switch back to the source, e.g. by double clicking the image or using one key-binding/command on it, for all types of preview images?


texts: How can I get an ftp connection to stop timing out in emacs?

texts:
I'm using M-x shell in Emacs and just connecting through vanilla ftp from the command line (bash).

I remember (many moons ago) I came across a script for Emacs that'd keep a persistent ftp connection going for shell/bash/ftp, pinging the remote server every 30-60 seconds and thus stopping the connection from timing out, and saving me the hassle of entering the connection strings over and over.

Is there a LISP script for this task? Or how does everyone else do it?

I use ftp over TLS. My remote shared host doesn't support ssh.


texts: How can I check if a user has pressed a button while a function is running?

texts:
I have a function that automatically runs after the user does some action. However, the function takes a long time to complete. This means Emacs becomes unresponsive for a short time after every input. To fix this, I'd like to check whether the user has entered a new input and if so, cancel execution of this function and proceed with the user's input.

Is there a variable that holds queued keyboard inputs? If not, is there another way to check whether the user has pressed a button since a function started running?


texts: Removing all overlays with duplicate values

texts:
My goal is to delete all duplicate overlay values from a list, and then remove every overlay in the buffer with values equal to each remaining element in the list.

I am having trouble understanding why remove-overlays does not remove every overlay in the buffer containing a specific value.  What appears to be happening is that remove-overlays removes just the first overlay it finds matching that specific value, and then it moves on to the next task without deleting the remainder of overlays with that same value.

I would like to delete duplicate values from the list using (delq nil (delete-dups ov-list)).

EXAMPLE

A test buffer contains the following text on the first line in the buffer:

############################

The code I am using is as follows:

(let* (ov-value ov-list overlay limit char-at-point)
  (save-excursion
    (goto-char (point-min))
    (setq limit (point-at-eol))
    (while (re-search-forward "#" limit t)
      (setq character (char-after (point)))
      (setq overlay (make-overlay (point) (1+ (point))))
      (setq ov-value (concat
          (propertize (char-to-string ?\uFEFF) 'face '(:background "yellow"))
          (propertize (char-to-string character) 'face '(:foreground "green"))))
      (push ov-value ov-list)
      (overlay-put overlay 'display ov-value)))
  (sit-for 2)
  (delq nil (delete-dups ov-list))
  (dolist (ov ov-list)
    (remove-overlays nil nil 'display ov)))


texts:
Friends, I have put strong effort to write an understandable account of the problem. Thus, I ask you to open all the site links quoted at the place of citation to follow the problem history.
I have emacs 24.5 on windows. It was installed circa 2015 and had working elpa downloading. It was not maintained for almost 4 years and now when I tried to run package-list-packages, it would not work. Searching over the web, I found that it was not making proper connection due to gnutls. I have melpa inclusion code per the link
Xah Lee site: http://ergoemacs.org/emacs/emacs_package_system.html
I have followed the installation of gnutls library and libxml2 per instructions at the site
http://חנוך.se/diary/how_to_enable_GnuTLS_for_Emacs_24_on_Windows/index.en.html
till the point before the certificate. At this point, I have tried instructions at this link to confirm TLS:
https://melpa.org/#/getting-started
and this command worked:
M-x eww RET https://wikipedia.org RET.
Now, I ran package-list-packages which brought down packages that required emacs25 as it was in the prerequistes. Thus, I selectively installed one python package and then deleted it. However, since that time, the package-list-packages does not work. It worked just once after the wikipedia. The wikipedia contacting works though.
The error is in the heading
ad-Advice-package--add-to-archive-contents: Symbol's function definition is void: package-desc-vers
I have traced that it arises from
(package-initialize) inside .emacs since the startup does not bring any scratch buffer but also starting with debug does not give any trace, which it did when I might have deleted a paren and that is how via debug that I found its location and fixed it.
I have commented out the line: (package-initialize) to verify that it stops the error message. However, it is necessary to use package.
Now, I have searched for the above message and found this link:
https://gist.github.com/don9z/5945914
but I cannot find any
melpa-autoloads.el in my installation folder.
Also, I have searched for the string
"package-desc-vers" in all .el files in the directory
emacs-24.5\share\emacs\24.5\lisp\emacs-lisp
and the top folder
emacs-24.5
and found no presence.
The link https://gist.github.com/don9z/5945914 listed above seems to indicate a typo, if you look at the patch indicated.
I also tried to recompile the package.el file and it recompiled and gave this message:
Leaving directory `C:\Program Files\emacs-24.5/'
Compiling file c:/Program Files/emacs-24.5/share/emacs/24.5/lisp/emacs-lisp/package.el at Fri Aug 21 13:43:19 2020
Entering directory `c:/Program Files/emacs-24.5/share/emacs/24.5/lisp/emacs-lisp/'
In package-compute-transaction:
package.el:973:18:Warning: function package-compute-transaction used to take
0+ arguments, now takes 2-3
In package--add-to-archive-contents:
package.el:1035:8:Warning: function package--add-to-archive-contents used to
take 0+ arguments, now takes 2
But this still did not solve the problem. The idea was that .elc might be inconsistent with .el.
I opened and searched package.el and did not find any instance of a typo like
package-desc-vers
Also, I have run "trace-function" on package-initialize and the trace after expanding it using visual-line-mode and linum-mode shows only one .el/.elc file being visited and that is
C:/Program Files/emacs-24.5/share/emacs/24.5/lisp/emacs-lisp/package.elc
Thus, I exhausted all the diagnostics I could do and need help from the Pros. Please explain a bit more clearly and instruct in diagnostics that I can run. I would prefer not to update to a later version and stay with this one if possible and I would like to get package listing results from elpa/melpa etc that are consistent with the current version.
How do I uninstall the current package.el without losing other installed packages data and then reinstall package.el again?
I guess this is like uninstalling apt and then reinstalling it in linux.


texts: Can which-key help with extended keyboard shortcuts?

texts:
I have two shortcuts defined like this

;; eval in shell
(global-set-key (kbd "C-c x s") 'eir-eval-in-shell)

;; eval in ruby
(global-set-key (kbd "C-c x r") 'eir-eval-in-ruby)

which-key helps me when I forgot my keyboard shortcuts.

The problem is, When I press C-c and wait 1 second I don't
get any useful info about the above 2 combos.

What I get is

& → +prefix     e → er/expand-region h → experiment-001 m → experiment-002 → +projectile-command-map
b → bury-buffer f → ffap             i → experiment-003    o → experiment-005 x → +prefix
C-c-  [C-h paging/help]

But

x → +prefix

doesn't help. Any ideas what to do here?


texts:
Where are org-mode issues tracked? What I mean, why I ask:
I'm having a problem with arbitrary text immediately preceding inline markup, which is the best way I can find to express the general problem underlying e.se.com posts like this and this and this. It's a problem I've previously encountered in reST. However,

reST has (IMHO) a reasonable, general, and clean solution for the general problem
IMHO the several workarounds I've seen offered for this problem in org-mode (see comments to the above questions) are either kludges or don't WFM. (YMMV, and note I'm not here to argue this point--it's just part of the motivation for this question.)

At least one of the comments to the above questions suggested that this might/should be a bug on org-mode, so I thought I'd check. Assuming that Org would track their issues in the same UI with their repository (welcome to the 21st century ?-) I searched for their repos, which are here, and particularly found the org-mode code repo here. It's a Gogs instance, and looks like a "normal" git front-end (e.g., bitbucket, github, gitlab) but ... no bugtracker?
I did some more websearching and I got nothing. So apologies if

my websearch was incompetent. I searched but did not find, and am not posting this to LMGTFY.
this question should be asked in another SE. Given that org-mode is such a major part of Emacs, I guessed this would be the place to post, but ICBW.

... but I'd like to know, how to view org-mode issues? E.g., in order to see if a bug or feature has already been proposed?


texts: How to run functions inside auto-insert template

texts:
I have this in my init file

(use-package autoinsert
  :ensure t
  :init
  ;; Don't want to be prompted before insertion:
  (setq auto-insert-query nil)

  (setq auto-insert-directory (locate-user-emacs-file "templates"))
  (add-hook 'find-file-hook 'auto-insert)
  (auto-insert-mode 1)

  :config
  (define-auto-insert "poolchem.org?$" "poolchem.org"))

IOW, I have the template file poolchem.org in ~/.emacs.d/templates/, which contains six tables. I went this route because it seemed easier than hand-tooling such a big thing in (customize-variable 'auto-insert-alist). But I would like various bits of embedded initialization code to run upon creating poolchem.org, e.g.,

(org-read-date nil nil "++mon" nil (org-time-string-to-time "2020-03-31"))

should place the date of the next Monday after 2020-03-31 in the text upon file open. How can I do this? I've experimented with eval of org-sbe in # local variables: ... but that was handy for running code blocks upon file open, not individual embedded functions.


texts: How can I generate a buffer and render html in it?

texts:
I want to make a buffer in a new window (but not pop to it) insert HTML code in it, and render its content with shr-render-*. Yes, an HTML preview window, let me know if you know of a (simple) existing implementation ; I tried various strategies, like temp buffers :

(with-output-to-temp-buffer "foo"
  (print (format "%s" "
plop
"))
  (print standard-output)
  (shr-render-buffer))

But this opens yet another window, and I lose my original window ; Ideally, what I'd like is a help buffer, but I'm guessing they are read-only..?


texts:
I have a problem with setting up rust-playground on Emacs.
I installed rust-playground on Emacs 25.0.93 of Macbook Pro.
When I run rust-playground, the following error happens.

rustc /Users/hirokinoguchi/.emacs.d/rust-playground/at-2017-05-16-150310/snippet.rs -o snippet &&
/Users/hirokinoguchi/.emacs.d/rust-playground/at-2017-05-16-150310/snippet

/bin/bash: rustc: command not found

Compilation exited abnormally with code 127 at Tue May 16 15:03:12

I can run rustc command on bash on Emacs.

Maybe I need to set up rustc's PATH in a elisp file.

Could you give me some advice?

I'd appreciate your help.


texts:
So as you can see, in my terminal, I was able to execute the file without error, but once I tried from the python shell, whether in the terminal or the one integrated in Emacs, there is an error, it doesn't know __file__
It seems that to get the file name, I instead can use :
import inspect
print(inspect.getfile(lambda: None)

But this feels like a hack more than proper python usage.
So generally how do other Emacs people face this issue of the python-shell? It's probably not the only difference (is it?). Should I stop using this shell and use term instead from now on to get the proper result of executing a python file?
(I'm rather new to both python and Emacs.)


texts: why defcustom variable is not seeable from describe symbol?

texts:
take org-brain-path for example:

(defcustom org-brain-path (expand-file-name "brain" org-directory)
  "The root directory of your org-brain.

`org-mode' files placed in this directory, or its subdirectories,
will be considered org-brain entries."
  :group 'org-brain
  :type '(directory))

I want to check its current value with describe-symbol org-brain-path, but I cannot find org-brain-path in describe-symbol list.

Why and how to check the current value?


texts:
I have set magit-repositories-directory like this:
(setq magit-repository-directories
      `("~/go/src/github.com/cescoferraro" ,user-emacs-directory))

Then I can M-x magit-list-repositories RET and I get a nice list containing all Git projects inside that folder.
Issue 1
I get Name, Version, L<U, U>L and Path columns.
But what does L<U, U>L mean? I get 0 values for only random repos. I could not figure out what it means. Ideally I want to know if there is something modified that needs to be pushed and if there is something at origin that needs to be pulled.
Issue 2
I want to use this as a sync tool. So I want to be able to push/pull and open magit-status for each project as I browse the list.


texts: Why do packages remain in `package-selected-packages`

texts:
I'm using Spacemacs, and I'm adding things to my dotspacemacs-configuration-layers. I can see its adding tons of packages to package-selected-packages.

If I comment out 1 or 2 layers (that I tested and don't want), when I reboot Emacs, I see it's "uninstalling packages," but for some reason they're still listed in package-selected-packages. How come it doesn't auto-remove them from here? I have so many packages for layers I was experimenting with that I don't want in there.

Thanks


texts: How can I export to LaTeX every time I save an Org mode buffer?

texts:
I'm trying to set up a buffer-local behavior so that optionally, only after I execute the babel section, Org exports to LaTeX asynchronously after each save. I tried the following:

(defun kdm/org-save-and-export ()
  (interactive)
  (org-latex-export-to-latex t))

(add-hook 'after-save-hook 'kdm/org-save-and-export)

But it creates file.tex.tex.tex.tex indefinitely. How do I modify this to only save 1x, and be a buffer-local change?


texts: How to highlight the current scope with C family languages?

texts:
While it's possible to highlight a block using the character under the cursor, is there a way to highlight the scope of the current cursor?

I'm interested in something like QtCreator's block-highlight feature:

Are there existing packages that do this or should I make my own?


texts: using gnuplot dumb terminal ASCII graph in org-mode

texts:
gnuplot ASCII graph is amazing.
I'd like to include gnuplot dumb ASCII graph results in babel code block.

#+BEGIN_SRC gnuplot :results output :file gnuplot-dumb-plot.txt
set term dumb
set yrange [0:1.5]
plot [-2:2] exp(-x*x)
#+END_SRC

#+RESULTS:

Alas, first line of gnuplot-dumb-plot.txt includes ^L line feed control code.

Therefore, #+RESULTS: does not work.

Adding another #+INCLUDE: with example block specified does work.

#+INCLUDE: gnuplot-dumb-plot.txt example

or excluding first line with :lines specified,

#+INCLUDE: gnuplot-dumb-plot.txt example :lines "2-"

or by sed deleting first line

#+BEGIN_SRC sh
sed -e '1d' gnuplot-dumb-plot.txt
#+END_SRC

work, but are not elegant.

#+RESULTS:
#+begin_example
      +--------+-------+--------+--------+-------+--------+-------+--------+
  1.4 +-+      +       +        +        +       +        +       +      +-+
      |                                                  exp(-x*x) ******* |
      |                                                                    |
  1.2 +-+                                                                +-+
      |                                                                    |
    1 +-+                              ****                              +-+
      |                            ****    ****                            |
      |                          ***          ***                          |
  0.8 +-+                       *                *                       +-+
      |                       **                  **                       |
  0.6 +-+                   **                      **                   +-+
      |                    **                        **                    |
      |                  **                            **                  |
  0.4 +-+              **                                **              +-+
      |              ***                                  ***              |
  0.2 +-+          ***                                      ***          +-+
      |         ***                                            ***         |
      +   ******       +        +        +       +        +       ******   +
    0 ****-----+-------+--------+--------+-------+--------+-------+-----****
     -2      -1.5     -1      -0.5       0      0.5       1      1.5       2

#+end_example

Are there any options or hacks for including gnuplot dumb ASCII graphs?

Thanks to @wvxvw, it turned out to be:

Note: Emacs 24.5.1, org-mode 8.3.2, gnuplot Version 5.0 patchlevel 1, Mac OS X 10.10.5.
:session none is required in gnuplot code block for printing ASCII graph in #+RESULTS: .

I wish if gnuplot has an option such as noheadfeed for deleting a top ^L / or, perhaps org-babel might manage in the future.

HTML export

:results output verbatim in gnuplot code block enables printing ASCII graph at #+RESULTS: within org-mode.
org-html-export-as-html works. This seems to be a simple solution if you don't need LaTeX.
But ^L appears in the beginning of #+RESULTS: which later makes error at LaTeX.

LaTeX export

Due to ^L, "Forbidden control sequence" in LaTeX, org-latex-export-to-pdf fails.
For LaTeX export, do not C-c C-c at gnuplot code block. #+RESULTS: at gnuplot should be left blank.
:exports none is also required in gnuplot code block for avoiding LaTeX error.

Org-mode, HTML, LaTeX

@wvxvw's solution removing ^L (\014) succeeds in org-mode #+RESULTS, HTML/LaTeX exports.
Use #+NAME: , :var , #+CALL: for output a clean ASCII graph #+RESULTS: (without ^L)


texts:
When launched at system start-up, the Emacs daemon doesn't pick up modifications to the PATH introduced by shell initialization scripts.
Emacswiki suggests to use this function to update Emacs' PATH,
(defun set-exec-path-from-shell-PATH ()
  "Set up Emacs' `exec-path' and PATH environment variable to match
that used by the user's shell.

This is particularly useful under Mac OS X and macOS, where GUI
apps are not started from a shell."
  (interactive)
  (let ((path-from-shell (replace-regexp-in-string
              "[ \t\n]*$" "" (shell-command-to-string
                      "$SHELL --login -i -c 'echo $PATH'"
                            ))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

(set-exec-path-from-shell-PATH)

but it returns some errors:
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
stty: 'standard input': Inappropriate ioctl for device

As far as I understand (my main reference), since I want to run Bash in interactive mode (so that it loads ~/.bashrc) I should use start-file-process(-shell-command) to invoke the shell process. However, I can't figure out how to store the output of the command in a string when I do so.


texts: Setting fill-column for reStructuredText mode

texts:
I can't set fill-column in reStructuredText mode hook:

(add-hook 'rst-mode-hook
    (lambda()
      (setq auto-fill-mode 1)
      (set-fill-column 60)))

While the auto-fill-mode works, the default fill-column is not changed, is there anything wrong with the code?


texts: Formatting output of inline org-mode source blocks

texts:
I want to include the output of inline code blocks in the LaTeX/PDF output of an org-mode document, but not in a monospaced font. I tried the following:

The mean petal length is src_R[:exports results :results raw]{mean(iris$Petal.Length)}.

which gives me this output in the LaTeX file:

The mean petal length is 3.758
.

The period in the sentence appears on a new line in the LaTeX file, which causes a space to appear between the code output and the period in the PDF.

Is there a way I can get the LaTeX output to appear all on one line so the PDF formatting is correct?


texts: Org mode export dispatcher nil and key binding

texts:
I have two questions for exporting org file to PDF:

I would like not to open Org Export Dispatcher when my org file export to pdf through LaTeX. I checked the manual, then I found the following:

  When the variable org-export-dispatch-use-expert-ui is set to a non-nil value, Org prompts in the minibuffer.

So, I set the following at my init.el. But it does not work. Are there any wrong for this setting?

(setq org-export-dispatch-use-expert-ui t)

To export a org file to a PDF file, I have to type C-c C-e C-l C-O. I don't like this key binding because of too much typing. Could you help me to set a concise keybinding?


texts:
I want to write a Makefile that handles org-export with ox-bibtex, e.g.

%.pdf: %.org
        emacs $< --batch -l emacs-load.el -f org-latex-export-to-pdf --kill

%.html: %.org
        emacs $< --batch -l emacs-load.el -f org-html-export-to-html --kill

where emacs-load.el contains any elisp needed.

And here start my problems:
I so far have

(add-to-list 'exec-path "./bibtex2html-1.98-linux/")
(add-to-list 'load-path "./elisp")
(require 'org)
(load "ox-bibtex.el")

and the ox-bibtex.el copied to elisp

With the above configuration, I get

Symbol's function definition is void: org-element-insert-before

If I provide a function definition (i.e. from org-element.el) org-link-types is void, and so on.

Apparently, I am missing something, but as it stands I do not know what to do in order to make ox-bibtex work.

I want the Makefile to be fully portable (i.e. not depend on a custom emacs configuration) for org-version >= 8.0. (But its OK to require some files in the same directory or a subdirectory.)


texts: Remove load average from time string displayed in mode-line

texts:
I like to show date and time in the mode-line. I currently have this in my .emacs file:

(setq display-time-day-and-date t)
(setq display-time-format "%I:%M %p %e %b %y %_5j")
(display-time)

How do I remove the cpu load average which always appears at the end of the time string? I've tried setting the variable format-time-string without any change in the load average display.

I've combed through the docs and also looked at global-mode-string without help.

As phils points out below, (setq display-time-default-load-average nil) addresses the issue.


texts: How to prevent emacs from fontifying empty part of the line?

texts:
As an example, if I start a one line comment:

;; Comment⏎

Emacs will fontify the the whole line, from the beginning of line, occupying the entire width of the window, as comment. This can be made easily visible by setting a background color for the comments.

Is there a way to make emacs only fontify the part of the line that's not empty?

Edit: This is the default behavior of emacs, and not a problem with the init file. You can see this by starting emacs with emacs -Q, open a lisp file, and then (set-face-background 'font-lock-comment-face "yellow")

(Thanks @lawlist)


texts: I use describe-function command with SPC h f to get help on emacs functions. But I want to get documentation on Doom's own functions such as map!. describe-function doesn't list this function. How can I get documentation on this and other custom functions?


texts: I'm in LaTeX/PS mode and whenever I close my $ math statements the cursor jumps to the first $ and back to the closing $. How can I disable this?