texts: Auto fill of # style comments in Emacs python-mode not working

texts:
My expectation is that, like for comments in other language modes besides python, I could write a long comment, say 150 chars, and it would automatically fill, i.e., newline and indent with comment starting newline, or at least allow me to do evil-fill (I use evil-mode) for same, but instead nothing happens. I have to manually format long comment lines that start with #.

In a python file, while in python-mode, when I do M-x auto-fill-mode it disables auto-fill-mode so I know it is turned on. Initially I thought maybe that was it. C-h v auto-fill-mode says its value is -1, not sure if that matters (but it did seem weird since a negative value usually means it is turned off - but in this case, since auto-fill works in """ comments, I know that can't be the case).

Also, it does auto-fill, as I type, comments in a python docstring """ environment.

Perhaps this is default and expected behavior (for most python programmers), I don't know.

Does your Python config auto-fill # style comments? Have an idea what to look for to make it do this?

Update: I do find that filladapt-mode mostly resolves the issue: (1) It nicely handles filling inside a """ style comment, (2) but, while it does fill inside a # style comment, it does not automatically start each newline with a # character. Not a big deal but something I need to see about enabling.

Update: Actually, I finally found a setup that works great for filling both style python comments. I give the use-package config I use to enable it in my answer below.


texts: Replacement in loop as a single undo item in buffer-undo-list?

texts:
I have this loop:

(catch 'QUIT
  (while
      (search-forward-regexp "\\([^\n\\]\\(?:\\\\\\\\\\)*\\|^\\(?:\\\\\\\\\\)+\\)%.*\n"
                 nil t)
    (save-excursion
          (let ((b (make-marker))
        (e (make-marker))
        MatchedStringOverlay
        ACTION)
        (set-marker b (match-beginning 0))
        (set-marker e (point))

        (setq MatchedStringOverlay (make-overlay b e))
        (unwind-protect
        (progn
          (overlay-put MatchedStringOverlay 'face '(:background "OliveDrab1"))
          (setq ACTION (read-char "Options:
- [y] erase string and the corresponding \"newline\"
- [l] erase string keeping the corresponding \"newline\"
- [n] skip
- [q] quit:
"))
          (cond
           ((char-equal ACTION ?y)
            (replace-match "\\1"))
           ((char-equal ACTION ?l)
            (replace-match "\\1\n"))
           ((char-equal ACTION ?n)
            nil)
           ((char-equal ACTION ?q)
            (throw 'QUIT nil))
           )
          )
          (remove-overlays b e))
        )))
  )

that performs some interactive replacements on buffer.

Now it happens that when I do undo after the loop, the command "undoes" all the replacements I made within the loop. How can I make each replacement a "single item" in buffer-undo-list?

Please, do not blame me... I'm really trying to find the infos by myself. I've searched in the docs, in the internet and I red the code of undo command but I've not been able to find how to get what I need.

EDIT. I think I shoud add a nil in buffer-undo-list to mark the boundary between two change groups (see here). So I tried

(add-to-list 'buffer-undo-list nil)

just before the first cond group but it does not work.


texts: call write-file interactively with prompting

texts:
I have a function that creates a buffer, with a default file name, and would like the first user action for that buffer be a prompt to write the buffer to a file, allowing the user to change the default, but offering the default in the minibuffer prompt.

The best result of all the options I have tried so far does properly associate the desired filename and path with a buffer, and does prompt the user, but does not offer the default name as a default.

Here is one of the best versions of the test function:

(defun my-write-test ()
  (interactive)
  (let*
     ((name "foo.txt")
      (path "/home/me/foo.txt")
      (buf (create-file-buffer name)))
   (pop-to-buffer buf)
   (insert "random text\n")
   (set-visited-file-name path)
   (call-interactively 'write-file (vector path))))

My guess is that I am somehow not properly defining the vector argument to function call-interactively, but I could be wrong; Maybe I'm just using the wrong elisp function?


texts: reference mutltiple selections or registers for shell-command-on-region

texts:
C-u M-| is wonderful for things like running sort a region. But I've wandered into an interesting place. I wan to run join or comm on two regions in a buffer.

# region 1
a 1
b 2
z 26

# region 2
a foobar
b 2
c 3

and I want join -j1 <(region 1) <(region 2).

I think registers or secondary selection could make this easier than the albeit already quick

  # select region 1
  M-| cat > /tmp/r1
  # select region 2
  M-| cat > /tmp/r2
  # position cursor below
  M-| join -j1 /tmp/r[12]

I don't see anything about referencing registers or selections in shell-command-on-region but maybe there is a similar command, universal argument, or package?
Would it be outrageous to point to files through /proc or a la elfuse

(Edit: example output -- current buffer)

# region 1
a 1
b 2
z 26

# region 2
a foobar
b 2
c 3

# join -j1 /tmp/r[12]
a 1 foobar
b 2 2

# comm -12 /tmp/r[12]
b 2


texts:
I am trying to use calc to modify equations in an org mode buffer. Activating calc in embedded mode works, but not without opening the calc stack buffer itself. That is, C-x * e puts the CalcEmbed mode line on my org buffer, and makes the buffer unmodifiable. However, the major mode remains Org. I have to run C-x * c to open the calc stack buffer, from where I can edit the equation, and have the changes automatically reflected in my org buffer.

Based on my reading of the manual, it seems like no stack buffer should be required. To whit:

  When Embedded mode begins, Calc pushes the current formula onto the stack. No Calc stack window is created; however, Calc copies the top-of-stack position into the original buffer at all times. You can create a Calc window by hand with C-x * o if you find you need to see the entire stack.

source

Am I misunderstanding? I should note that I'm using evil, so keys like a and f are shadowed by the evil bindings. If I'm not misunderstanding, how can I more or less "turn off" evil mode for the duration of the Embedded Mode session?


texts: Nano not displaying correctly in term and ansi-term

texts:
Nano is displayed incorrectly in emacs when using term or ansi-term. This is what nano is supposed to look like (run in an ordinary terminal emulator):

This is nano as run from ansi-term:

In the above picture, you can see that the first line of commands is missing.

The same behavior appears in GUI and CLI mode, and running emacs with --no-init does not fix the problem.

Since I know the nano commands, this is only a minor nuisance, but it's pretty annoying. Is there any way I can fix this issue? I don't want to use the other terminal modes in emacs for various reasons.


texts:
I'm trying to understand this value assignment:

(setq mouse-wheel-scroll-amount '(2 ((shift) . 1)))

I know that shift is a bitwise shift. But I don't understand what is the result of this operation here (what is the value of mouse-wheel-scroll-amount). And for that matter, why did the coder decide to use this operation rather than giving a decimal value here.


texts: From an org heading, pressing evil o will open a new line that's indented according to the heading (org level + 1 spaces).  Can this behaviour be turned off?


texts: comint-exec with very large argument list on windows

texts:
I wish to start a command that has a very large argument list (10s or 100s of thousand characters) with comint-exec but when I do this on Windows it fails to start.

The only error is

apply: Spawning child process: exec format error

and I've confirmed that it is the argument length that causes the problem by reducing the list and the process starts up (but that's no good because I need the arguments to be able to get any use out of the process I'm spawning, which is a java command with an extremely large classpath).

This sounds similar to https://stackoverflow.com/questions/2261071 but it's not the same.


texts: What is the standard way to install an elisp package?

texts: I'm interested in trying out the features of the htmlize.el package that I read about here. The article does not explain how I can import it into emacs. What is the best way to do this?


texts: dvorak and korean language input in emacs

texts:
i recently switched from qwerty to dvorak. i also need to type in korean, and i use nabi to input korean everywhere outside of emacs. thankfully, nabi has support for dvorak. unfortunately it doesn't work well with emacs and spaces keep getting inserted where they should not be. when i used qwerty i used emacs's internal set-language environment and it worked great--i am having some difficulty with getting the korean keyboard layout to work with dvorak though.
upon doing some research, i've found that i'm not the first to have this problem.
I first tried the stuff laid out here:
https://www.emacswiki.org/emacs/WritingRussianWithDvorak
https://github.com/alezost/dvorak-layouts.el
unfortunately after i copied and modified the cyrillic file for korean, it turns out that this only types the letters out but it can't put them together (e.g., the letters ㅇ ㅏ ㄴ should make 안 when typed out but they don't combine...
i then tried this
https://github.com/mrkkrp/fix-input
I copied the example given for fix-input but it doesn't work.
(fix-input "english-dvorak" ;; matches alternative layout

"korean-hangul" ;; works with QWERTY

"dvorak-korean") ;; name of new input method that preserves

;; the same layout with Dvorak

and finally i found this How to switch keyboard layouts for different languages?
i added the dvorak as a keyboard layout, but i'm not sure if i'm supposed to do anything after that because the korean still comes out w the keys corresponding to the qwerty letters
my technical know how (such as it is) ends here, because i'm not sure what to try next. this is probably just placebo but my hands feel much better after just about a week of typing on dvorak and i'd like to be able to continue using it, if possible. any assistance would be greatly appreciated!


texts: Fontify result of source block in org-mode

texts:
Let's say I have a source block containing a shell command that outputs some C code.  For instance

#+BEGIN_SRC sh :results verbatim :exports both
echo 'const char* str = "foo";'
#+END_SRC
#+RESULTS:
: const char* str = "foo";

When I export that to HTML, for example, the shell code is fontified like shell code.  However the result is not fontified, since org does not know it is actually C.

How do I fix that?  Is there a way to hint that the result of some command is in another language?

Reading the documentation of :results it seems I might want use option code to specify that the output is some code, but that seems to assume the output uses the same language as the input:

#+BEGIN_SRC sh :results verbatim code :exports both
echo 'const char* str = "foo";'
#+END_SRC
#+RESULTS:
#+BEGIN_SRC sh
const char* str = "foo";
#+END_SRC

Is there a way to specify the language of the output?


texts: How to include headers when exporting a message as PDF?

texts:
As a follow-up to this question about exporting as PDF, I want to export a message as a PDF. One answer in that thread views the message in a browser window and I can then save as a PDF from the browser:

(add-to-list 'mu4e-view-actions '("ViewInBrowser" . mu4e-action-view-in-browser) t)

The other is similar but does the work behind the scenes with WebKit HTML to PDF. Here is one example of the output of the latter command:

Both miss the header fields, such as sender, date, and subject, and the message starts immediately at the body.

How can I include message headers when exporting to PDF?


texts: How to embed svg output of org-mode src block as inline svg in html export?

texts:
I wish to embed the svg file output of gnuplot as inline svg code in the html export. Currently I do the following:
1. Manually remove the RESULTS block.
2. INCLUDE the svg file as shown in the MWE below.

How can i configure the RESULTS block to do what I want automatically?

#+BEGIN_SRC gnuplot :file example-plot.svg :exports code
plot sin(x)
#+END_SRC

#+RESULTS:
[[file:example-plot.svg]]

# I manually remove the above RESULTS block
# and insert the following INCLUDE

#+INCLUDE: "example-plot.svg" export html


texts: Change list bullets in org-mode depending on embedding level

texts: Is it possible to change the face of list bullets dynamically, mimicking the behaviour of WYSIWYG textprocessors like MS Word?


texts: Stdlib support for compile-time metaprogramming?

texts:
The following macro...

(defmacro compile-time-eval (&rest body)
    (eval (cons 'progn body)))

...allows for compile-time metaprogramming like this (a small contrived example) :

(compile-time-eval
 `(defun join-dirs (a b)
    (concat a
            ,(if (eq system-type 'windows-nt)
                 "\\"
               "/")
            b)))

Is something like compile-time-eval part of the standard library? (eval-when-compile comes close, but it quotes the result.)

If not, what's the recommended way to implement this example?


texts:
I want to create a new frame that contains nothing but the mode-line. Especially not a file buffer.

Why do I need this? I use org-mode's clocking to time my work. Org-mode displays the timer for the current task I'm working on in the mode-line, and updates the timer in real-time. I use apps other than Emacs, so when I switch to them (e.g.. when using the browser or terminal) I still want to be able to look at the running timer. I thought I could create a new frame, but when I now click on the timer in the mode-line the .org file is getting opened in the new frame (which is already resized to show only mode-line) instead of jumping back to it in the first frame.

Here's how my mode-line looks (the blue bar) -- that is all I want on the new frame:

(Eventually I will have to figure out how to make the new frame appear always-on-top, but that is outside the scope of this question)

I use OS X if that is relevant.


texts:
org-goto (as well as orgnav, helm-org-rifle) strictly respects narrowing. is there a way to have it disregard it, making it possible to jump to places in the file outside current narrowing? or is there another way to jump around this way?
i would like to use it jump somewhere anywhere in the present file, paste or copy something, then return to where i was working.
i currently use org-goto with path completion, and in the completion minibuffer, all headings from the current file are shown, not just those in the narrowed buffer. so it gives you the impression that it will move to any heading in the file, but then it fails to take you anywhere if you select a heading outside the present narrowed buffer.
but perhaps there's another way to achieve this?


texts:
paredit.el has the following example code for setting a keybinding:
https://github.com/emacsmirror/paredit/blob/8330a41e8188fe18d3fa805bb9aa529f015318e8/paredit.el#L54
    (eval-after-load 'paredit
      '(progn
         (define-key paredit-mode-map (kbd "ESC M-A-C-s-)")
           'paredit-dwim)))

Evaluating (kbd "ESC M-A-C-s-)") outputs [27 213909545].
How to interpret this vector key sequence. What keys does this represent?


texts: C++ lsp-mode: inconsistent behavior between remote and local projects

texts:
I've run into a bit of an odd problem trying to use lsp-mode.
My problem setup is as follows: I'm working on a C++ project on my computer, and I'd like to be able to use lsp-mode with it. The catch is that it's big, big enough that I can only build it on a remote VM with a bunch of resources.
The C++ lsp requires a compile_commands.json file, which needs to be generated by the build system. Our project is set up to build kinda weirdly, so I generate this file on the devbox via bear. At this point I should note that lsp-mode runs flawlessly if I ssh into the devbox and open emacs with emacs -nw.
Unfortunately, due to latency issues I really need to be able to edit the code locally and have all the nice lsp features while doing it. Therefore, I copy over the compile_commands.json to my local copy of the repo: it contains some absolute paths to the project on the devbox, so I update all of those via sed to point at the local copy.
I know this process can work, because I actually had it working flawlessly not two hours ago: complete parity with the ssh + emacs -nw experience. Unfortunately I kept messing around after that, checking out different branches, regenerating/copying the compile_commands.json, minor stuff like that. Now the process isn't working nearly as well as it used to, even after bringing the local and remote repos to the same states and running the same commands as the time when it worked.
I know that my way of bringing in the compile_commands.json is still doing something useful, because without it none of the lsp stuff works at all (as expected). However, the local lsp-mode is less functional than over ssh + emacs -nw, in at least a few ways

lsp-find-references wont find all, or sometimes even any, of the references to the symbol under point. In fact, if I try to find references to any member of a class it will just try to find references to the class itself: and even then it will only find the actual class definition itself, not even usages which I could detect via ctrl+f
lsp-find-definition sometimes just straight-up wont work: displaying the following error in the minibuffer cl-no-applicable-method: No applicable method: xref-item-location, nil
lsp spends a lot of time indexing in the background (updating with % progress in the minibuffer). This indexing takes a long time, and doesn't help at all once it has finished. Moreover, although the indexing creates a ".cache/clang" directory, every time I restart emacs it indexes the project all over again with no discernible performance improvement.

ssh + emacs -nw displays none of this behavior (it does create a cache dir but doesn't mentioning indexing in *Messages* at all, and quite frankly I'm baffled as to why.

The only difference I can think of in the one time I got it working was that lsp didn't auto-discover my local project- when I opened my first .cpp file, I got some sort of lsp menu at the bottom of my emacs window with four options asking me how to set the project root (I think I ended up hitting enter to take the default option). I have never seen that submenu again, despite having

Deleted and re-cloned the local project
Deleted all of my projectile projects
Deleted my ~/.emacs.d/.local/etc/lsp-session file
Uninstalled and reinstalled lsp (I use doom, so I did this by commenting out the "lsp" layer, running a doom sync, uncommenting it, and then doom syncing again)

Anyways, I was really hoping someone could help me out here. Figuring out how to properly delete all my lsp projects/caches and regenerate the project via that menu seems like a good starting point


texts: Get Emacs to indent fluent builder inside argument list

texts:
So emacs's java-mode handles indenting continued method invocations at the function body level out of the box, but it doesn't seem to handle them inside of an argument list. I'd like to override this behavior. I'm aware of C-c C-s, but in this particular example both the line that begins with Other and the line that begins with .newBuilder() are arglist-cont. I'd like to distinguish between these two cases. In the function-level example .newBuilder() is statement-cont, so that's why it's getting indented correctly. (I just realized that I do actually have (arglist-intro . +) set in my current style so that is why args[0] is getting indented once instead of aligning to the preceding parenthesis, but even without that setting, the .newBuilder() line still aligns with the other arguments instead of indenting one additional level.)

public class Foo {
    void main(String[] args) {
        /* This works just fine */
        Other
            .newBuilder()
            .fluent1()
            .fluent2()
            .build();
        /* This is how it works currently. */
        someMethodThatTakesOther(
            args[0],
            args[1],
            Other
            .newBuilder()
            .fluent1()
            .fluent2()
            .build());
        /* This is what I would like. */
        someMethodThatTakesOther(
            args[0],
            args[1],
            Other
                .newBuilder()
                .fluent1()
                .fluent2()
                .build());
    }
}


texts: (solved) Error "Tangled 0 code blocks from [file]"

texts:
I'm writing a bash script with literate org-mode.

The header of the file is:

#+TITLE: start-lcs
#+AUTHOR: Stahlberg
#+EMAIL: stahl at gmail dot com
#+DATE: 2019-11-02
#+PROPERTY: header-args:sh :tangle "start-lcs.sh" :shebang "#!/bin/bash" :padline no :tangle-mode (identity #o755)
#+OPTIONS: author:t date:t email:t H:3 num:nil toc:t ^:{}

There are 50 blocks of code, one of them is:

#+BEGIN_SRC sh
  readonly EC_SUCCESS=0
  readonly EC_GENERIC=100
  readonly EC_PROGRAM_NOT_INSTALLED=101
  readonly EC_CANCEL_BUTTON_PRESSED=102
  readonly EC_NOT_YET_IMPLEMENTED=103
#+END_SRC

The file ends this way:

# @ Local variables:
# @ org-src-preserve-indentation: t
# @ End:

How come that when I tangle the file (C-c C-v t) Org-mode returns Tangled 0 code blocks from start-lcs.org?


texts: .yas-parents have no effect with web-mode

texts:
I'm using web-mode and yasnippet for coding PHP and HTML.

To use yasnippet in web-mode, will have to install php-mode, php-auto-yasnippets, emmet-mode and ac-emmet as suggested in web-mode.org. But I prefer to make it happen just with web-mode and yasnippet.

Part of my web-mode configuration is like this:

(defadvice yas-expand-from-trigger-key (before web-mode-before-yas-expand activate)
        (run-hooks 'web-mode-cur-language-mode-hook))

(add-hook 'web-mode-cur-language-mode-hook
      '(lambda ()
         (let ((web-mode-cur-language
                (web-mode-language-at-pos)))
           (if (string= web-mode-cur-language "php")
               (yas-activate-extra-mode 'php-mode)
             (yas-deactivate-extra-mode 'php-mode))
           (if (string= web-mode-cur-language "html")
                (yas-activate-extra-mode 'html-mode)
              (yas-deactivate-extra-mode 'html-mode))
           )))

And following is my yasnippet configuration:

(add-to-list 'load-path (expand-file-name "elpa/yasnippet" user-emacs-directory))

(require 'yasnippet)

(yas-global-mode 1)

It works very well when edit php file in web-mode.

Then open a html file in emacs, input "form" then "tab", everything works fine. But if input "href" then "tab", nothing happened. It supposed to call the "href" snippet in nxml-mode as written in html-mode's .yas-parents.

How could I make this right? I really don't want copy all those snippets from nxml-mode to html-mode.


texts: Ignore all git projects under a directory for projectile

texts:
I am trying out exercism.io and whenever I fetch any problem and build, it gets added to projectile-known-projects and now I've  a whole bunch of projects under projectile-known-projects which I do not want.

So, is there a way to ignore all the git projects under a directory, in my case ~/exercism/ directory.

I tried adding ~/exercism/ to projectile-ignored-projects but that did not work(looks like it expects only the path to an actual project directory not a non-project directory which contains projects inside it)


texts:
I'm trying to figure out how to specify which version of python to run when calling "run-python" (C-c C-p) in python-mode, and I've run into the following problem. These are the first few lines of the definition of run-python:

  (defun run-python (cmd &optional dedicated show)

  "Run an inferior Python process.
  Input and output via buffer named after
  `python-shell-buffer-name'.  If there is a process already
  running in that buffer, just switch to it.

  With argument, allows you to define CMD so you can edit the
  command used to call the interpreter and define DEDICATED, so a
  dedicated process for the current buffer is open.  When numeric
  prefix arg is other than 0 or 4 do not SHOW.

I would like to specify the CMD argument so as to specify "python2" or "python3." For example, I've tried things like

  M-: (run-python python2)

  M-: (run-python (shell-command "/usr/bin/python2"))

but nothing works.

Edit: I figured out that if I supply 0 as a numeric argument, then there is a prompt where I can specify the python version. I would still like to know why neither of my attempts to specify CMD in the actual function call did not work though.


texts: Replace a filename in init.el using sed from bash script

texts:
So I have different customized themes.  Different customized themes are written to a separate custom .el files and get called in the main init.el file. For example:

(setq custom-file "~/.emacs.d/myCustomSettings/customDarkLaptop.el")

will call the customDarkLaptop.el, where all of my customized variables like font size, comment color..etc.

Suppose I want to switch to a different customized themes, I then go to init.el and change this

(setq custom-file "~/.emacs.d/myCustomSettings/customLight.el")

which will then load the customLight.el  file.

I would like to write a script to automate this process, user just need to enter either the part after custom to the desire theme.  For example:

enter Dark will automatically have customDark.el

Replacing text from a file can be easily be done with the sed command, i.e.

sed -i -e s/oldtext/newtext/g <enter file name here>

However, I am not sure how to incorporate this efficiently into my init.el file.  What I want is something like this:

create a string variable in init.el:  themeName = "Dark"
Append it to my set-q command file path like this:

(setq custom-file "~/.emacs.d/myCustomSettings/custom<INSERT THE VARIABLE themeName HERE>.el")

My sed script will just replace one thing, the variable themeName in init.el.

How do you do this in elisp?


texts: Why is emacs attempting to connect to remote bookmarks after I deleted them?

texts:
I had bookmarks to some files on windows servers for quick and easy access. Well, I lost access to the server (the account's password changed), so I 1) removed those entries from my bookmarks list and 2) saved the contents.

I verified that there are no references to these servers in the bookmarks, or in registers, however Emacs is still prompting me to log into these remote windows servers. I can't find out what is attempting to connect and where it's been configured.

I have to "Cancel" the Windows login/authentication dialog requests to server A three times, and server B 12 times, causing an incredibly long and painful start up process.

I've tried starting with --debug-init, but don't know where to find the log.

When I start Emacs with -Q I'm not prompted to log into those resources, but see no references to those hosts in my .emacs or any other config files. Where could it be coming from?

Thanks.


texts:
I often use text scaling, but it only seems to work on the default face.  This is a problem, for instance, when I write text that also has italics (e.g., markdown, org text).  The text scale commands change the size of the text with the default face but do not change the size of the text with italics face.

I define these faces like this (Inconsolata does not have an italic version):

(set-face-attribute  'default nil
                     :family "Inconsolata"
                     :height 130
                     :foreground "gray90"
                     :background "gray25")

(set-face-attribute  'italic nil
                     :family "Cousine"
                     :height 100
                     :slant 'italic
                     :underline nil)

Is there a way to make the text scale commands work on the italic face as well?


texts: How can I search through registers via counsel?

texts: I need something like helm-register which lists all the registers and it can be searched through.


texts: How can I find callers to a function/macro?

texts:
Given an elisp function or macro, does Emacs provide any way of finding callers?

Currently I'm just grepping in ~/.emacs.d for examples, but it's crude. Slime has slime-who-references but the excellent elisp-slime-nav doesn't seem to have an equivalent command.


texts: Access to the elisp "commands" behind eshell commands?

texts:
As I've read, eshell commands are just wrappers around actual elisp expressions. If true, everything I do in eshell I could do in an elisp REPL, right? Is it therefore possible to see what actual elisp is being invoked when we type in an eshell command?

The reason I ask is that I want to use org-mode's Babel. You can put elisp code in blocks and get results inserted after the block just fine. This is also true for regular shell (sh), but there is no way I know of running eshell commands as Babel "code blocks." So I'd like to have the actual elisp, which org-mode Babel handles in blocks well.


texts: How does one create back and forth communication to a process

texts:
I am writing an emacs mode that interfaces with a shell process. The shell process is expensive to start which means that I would like to do it once and then send commands to it from emacs as need be. How is it possible to do this asyncronous two way communication with an external program through emacs.

From what I understand comint mode is close to what I need but it seems like that is only to be used for a major mode where the user supplies the input like interfacing with the python shell.

I would like the actual process and shell to be hidden from the end user.

Is there a reasonably easy way to do this? Or some resources on the subject>

Thank you all


texts: Drop rows with zero time in org-mode agenda clockreport

texts: I recently found org-agenda-clockreport. Because I keep all my .org files in a single directory (indexed by deft), including files with notes and no tasks, I get a table with tens of rows, with only one or two that have any time logged. Is there any way to drop any rows in the clockreport that have zero time?


texts: Automatically use the title of a linked Org file as the link text

texts:
I have two Org files:

$ cat doc/index.org
#+TITLE: Leek Documentation

file:introduction.org
$ cat doc/introduction.org
#+TITLE: Introduction

How can I make the file:introduction.org link automatically use the title of the doc/introduction.org file as the link text (in this case: Introduction)? So that if I change the title, this change also gets reflected immediately in the link text.


texts: Emacs install folder vs .emacs.d vs .emacs/.emacs~ confusion [Windows 10]

texts:
I've recently run into complications regarding elpy and setting up virtual environments (see other questions) which have brought me back to a more fundamental issue that I must resolve before I continue integrating python functionality into emacs.
Details:

My HOME environment variable is located in c:\users\robby parliament
My root emacs install folder is located in c:\users\robby parliament\documents
The .emacs and .emacs~ files are also located in c:\users\robby parliament
The .emacs.d folder is also located in c:\users\robby parliament and contains the following items:

> - c:\users\robby parliament
> --- .emacs.d
> ----- auto-save-list
> ----- elpa
> ----- elpy
> ----- snippets
> ----- url

Questions:

When I move the .emacs and .emacs~ files into the .emacs.d folder I lose my theme (dracula), why is this so?
In response to the above question I figured I must change the HOME environment variable to `c:\users\robby parliament.emacs.d, so when I do that I get the following warning/error:

Warning (initialization): An error occurred while loading ‘c:/Users/Robby Parliament/.emacs.d/.emacs’:

Symbol's function definition is void: elpy-enable

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

Then when I move the .emacs and .emacs~ files into the .emacs.d subfolder within c:\users\robby parliament\.emacs.d the warning is now gone yet the theme is still gone. I've watched LigerLearn's tutorial on setting up emacs and the customization of the file paths several times but I feel like I'm still not understanding a fundamental concept which is bringing me all these warnings and errors. What am I doing wrong?

Also, this is within my .emacs file:

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(ansi-color-names-vector
   ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"])
 '(custom-enabled-themes (quote (dracula)))
 '(custom-safe-themes
   (quote
    ("b46ee2c193e350d07529fcd50948ca54ad3b38446dcbd9b28d0378792db5c088" default)))
 '(display-line-numbers t)
 '(package-archives
   (quote
    (("gnu" . "https://elpa.gnu.org/packages/")
     ("melpa" . "http://stable.melpa.org/packages/"))))
 '(package-selected-packages (quote (flymake elpy dracula-theme)))
 '(ring-bell-function (quote ignore))
 '(visible-bell nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
'(setq visible-bell 1)
(elpy-enable)
(define-key yas-minor-mode-map (kbd "C-c k") 'yas-expand)
(define-key global-map (kbd "C-c o") 'iedit-mode)


texts: Emacs HTML Export Options (Post- and Preamble)

texts: Is there a way I can declare some HTML pre- and post-amble content in a buffer (and only applying to that buffer) itself without needing to create a new org-publish-project-alist project or customizing the default org-html-preamble and org-html-postamble?


texts:
When I ran GNOME, I used to be able to click on any link in Emacs, and it would open in my default web browser.

But now that I'm using i3, it doesn't work any more, even though I haven't changed any Emacs settings. I don't get any messages or errors—it just does nothing. I also tried M-x browse-url-at-point, while on a URL, but that doesn't work, either.

As far as I can tell, I have the appropriate settings: browse-url-browser-function is browse-url-generic, and browse-url-generic-program is set to qutebrowser, my default browser. So why can't I open URLs? And/or how can I debug this?


texts: Change TODO keywords of all nodes in an Orgmode subtree in Elisp

texts:
Imagine we have a tree like this:

* TODO Read X book
** TODO Chapter 1
** TODO Chapter 2

I'd like to mark all nodes in the tree as DONE:

* DONE Read X book
** DONE Chapter 1
** DONE Chapter 2

What's the best way to do it in Elisp?


texts: Org-journal create a new bullet with timestamp within the existing journal entry

texts: If I create a new org-journal entry, the entry will open with an Org-mode bullet and a timestamp. If I already have a journal entry open though, is there a way to add a new bullet and timestamp from within the entry? I did not see any mention of that, but I figure it would not be very hard.


texts: Embbed html/javascript in org-mode html export

texts:
Is it possible to embed an html file within an html exported from org-mode?

I don't mean to "quote" the source of the file (which is possible with #+INCLUDE: "someFile.html" src html).

My use case is: I have a standalone html containing a simple D3 visualization. I'd love to link somehow to this html within org-mode so that once I export the org file, the visualization would dispay in the output html.

My current workarounds:

simple linking to the standalone html [[file:...]] so the visualization opens when user clicks on it.
Alternative is is to manually copy the code into the output html from org-mode - but this is highly impractical.

Thank you very much!


texts: How to conveniently insert a clock entry?

texts:
Sometimes I want to add a clock entry for something I did after it was already done. For example I may want to add an entry  CLOCK: [2017-01-28 Sa 09:35]--[2017-01-28 Sa 10:12] =>  0:37 at 10:30.

There doesn't seem to be any easy way to do it. The two methods I can currently think of are:

Copy a previous entry and modify its time, then press C-c C-c
Invoke org-time-stamp-inactive twice, and then manually type in all the rest (CLOCK:, -- etc.), and then press C-c C-c.

Is there any way I can do it easier, or should I just try to define a custom function for this purpose?


texts: Is it possible to disable flycheckspell for specific file names in text-mode?

texts:
I am actively using flyspell on all text files under text-mode.

For example: Under requirements.txt text file I am keeping my python packages where I do not need to enable flyspell. But since it is a text file flyspell keep does its checks. So I want to disable flyspell for specific file names like: requirements.txt and so on. It also enable in yaml-mode even I did not enable it.

My setup:

(flyspell-mode 1)
(setq flyspell-issue-message-flag nil
      ispell-local-dictionary "en_US"
      ispell-program-name "aspell"
      ispell-extra-args '("--sug-mode=ultra"))

(dolist (hook '(text-mode-hook))
     (add-hook hook (lambda () (flyspell-mode 1))))
    (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
      (add-hook hook (lambda () (flyspell-mode -1))))


texts: Nested git repositories that behave like one project with projectile

texts:
I am trying to understand how to use https://projectile.readthedocs.io/en/latest/projects/#customizing-project-root-files but it is not clear yet.

My goal is to have nested git projects. Let's say I have a directory structure like /a/{b,c}. Folders a, b and c have been created using git clone and all contain a .git folder. From project a, I'd like to be able to use projectile-find-file over files of a, b and c.

Is it possible? Am I looking at the good documentation? Is it possible to enable this behavior only from one directory by using .dir-locals.el?


texts: Can serial-term interpret new line characters as CR LF?

texts:
I'd like to read a serial link from Emacs using serial-term. The output looks wrong, like if the new line characters did not trigger carriage return:

First line
          Second line
                     Third line

Reading from this serial line using ansi-term shows the expected output:

A first line
A second line
Third line

I tried to use set-buffer-file-coding-system to unix in the serial-term buffer, but this did not change anything.

Is it possible to get serial-term to interpret new line characters as carriage return and a line feed?


texts: Alternative to `file-name-extension` that will include `~`

texts:
I am looking for an alternative to file-name-extension that will include an ending ~ if there is one.  For example, if there is a file named foo.el~, the result should be el~.

Rather than using the generic split-string, I was hoping there might be something more specific geared towards file extensions.


texts: How to properly auto-indent Org Mode multi-line list items?

texts:
I am typing a journal entry in org-mode as so:
I worked on my English paper today, and made lots of progress.
+ We used Emacs for our project
+ Some other people used vi, but I think Emacs Org mode really helps
  + One of the groups even used LaTeX, but I think Emacs AucTeX might be the best way to write LaTeX

This is what happens when I press RET between AucTeX and might.
I worked on my English paper today, and made lots of progress.
+ We used Emacs for our project
+ Some other people used vi, but I think Emacs Org mode really helps
  + One of the groups even used LaTeX, but I think Emacs AucTeX
might be the best way to write LaTeX

But why does it go back all the way to the very first column? I want might to be aligned with the word Org from the previous line... Would something like Fill-mode help here (never used it)? Right now I am just doing <space> however many times from the first column to align words in this case, but it is rather cumbersome. You would think TAB would work, but it doesn't seem to unfortunately..
What is the best way to maintain alignment in this case? Any help would be appreciated.
Edit: I would use auto-fill-mode, but I feel that sometimes it is too strict in making it's judgements.
Eg. say I have this paragraph as a list item:
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit some
  gibberish here. Phasellus sed massa quam. Morbi nec sollicitudin
  nulla. Ut pharetra lacinia hendrerit. Praesent purus ex, luctus non
  erat quis, interdum vulputate justo.

I usually like it when sentences are on one line. So I want the sentence "Lorem ipsum dolor sit amet, consectetur adipiscing elit some gibberish here." to be on the first line. However, since auto-fill-mode/M-q is strict, it won't allow me to do this.
I was wondering if there was a more general solution, like some hidden command I don't know about that creates a newline, but with the stuff after the newline being indented properly, just like M-q.


texts: I think, it'd make a lot more sense to have desktops be identified by names (like bookmarks). If it's deemed desirable that they can be stored in different locations, it'd make sense to select what file shall be used to store the desktop. So why does one have to select a directory instead (with the file name always being the same)?


texts: Clocktable formula to get average of a column in a single cell

texts:
I have a table I'm generating:
#+BEGIN: clocktable :maxlevel 0 :block thisyear :scope get-journal-files-for-current-year :fileskip0 t
#+CAPTION: Clock summary at [2021-05-19 Wed 20:31], for the year 2021.
| File         | Headline         | Time     |
|--------------+------------------+----------|
|              | ALL *Total time* | *178:27* |
|--------------+------------------+----------|
| 16_04-19.org | *File time*      | *38:18*  |
|--------------+------------------+----------|
| 17_04-26.org | *File time*      | *38:32*  |
|--------------+------------------+----------|
| 18_05-03.org | *File time*      | *38:07*  |
|--------------+------------------+----------|
| 19_05-10.org | *File time*      | *39:46*  |
|--------------+------------------+----------|
| 20_05-17.org | *File time*      | *23:44*  |
#+END:

I would like to get the average of all the rows in the Time column (excluding the 178:27 one). I can do this with a regular formula, say =vmean(@3$3..@7$3);T under the cell with 23:44 in it. I tried to do this with the formula: paramater to the clocktable, but I'm unable to do get exactly the behavior I want.
If I try formula: "@8$3=vmean(@3$3..@7$3);T", I get an org-clocktable-write-default: Args out of range: [nil 0 2 4 6 8 10 12], 8 error.
If I do :formula "$4=vmean(@3$3..@7$3);T", I get the right values, but in every row in the fourth column (and if I try to do ...@>=$3, to get all the rows in the third column, I just get a blank column.)
How do I get a single cell with the average for the third column in it that excludes the 178:27 cell?
Thank you.


texts:
I'm noticing something really odd in my ansi-term windows on my new Mac, see below:

I am using:

GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version 10.12.6 (Build 16G1036)) of 2017-11-10

which I installed using brew using:

brew install emacs --HEAD  --with-cocoa --with-ctags --with-dbus --with-gnutls  --with-imagemagick@6 --with-mailutils --with-modules

Note that:

I see this problem even with emacs -Q.
I also get this problem when using  https://emacsformacosx.com/

oh-my-zsh and termsupport.sh

I only seem to have this problem when I load oh-my-zsh. As I mentioned in a ticket I opened with them, the problem seems to be termsupport.sh specifically. The problem only happens if oh-my-zsh loads that file.


texts: non-character input-event when using rectangular commands since version 24.4

texts:
Since version 24.4 and till 25.1 when I want to make a rectangular copy C-x r r RET I got the following message: non-character-input-event

It appears that this problem happens only for rectangular copying but not for all other options (killing, yanking, deleting).

This happens on the following OS: Windows 7,8 and 10.


texts: Force new lines between words in cell of org table


texts:
When I use emacs 24.3.1 and run

/usr/bin/emacs -Q

Then M-< followed by M-xglobal-hl-line-mode and M-xdescribe-face, emacs asks me

Describe face (default `font-lock-comment-delimiter-face'):

But when I use 26.1 and run

/usr/local/bin/emacs -Q

and run exactly the same commands, emacs asks me

Describe face (default ‘hl-line’):

I have to turn hl-line off to get the name of the point's face. What causes this difference and is there a way to get the old behaviour back?

Update:

It seems

(get-char-property (point) 'face)

returns hl-line in 26.1, but returns the actual face in 24.3.1.


texts: Can a code snippet scan an org file to generate multiple new org files?

texts:
I have a file ~/documents/foo.org which looks like

#+TBLNAME: data
|                  |                  |        | p01a | p01b | p02 | p03 |
|------------------+------------------+--------+------+------+-----+-----|
| e-mail           | name             |  total |    5 |    5 |  10 |  25 |
|------------------+------------------+--------+------+------+-----+-----|
| gh01@beatles.edu | Harrison, George | 80.00% |    5 |    4 |   7 |  20 |
| jl01@beatles.edu | Lennon, John     | 75.56% |    5 |    3 |   5 |  21 |
| pm01@beatles.edu | McCartney, Paul  | 86.67% |    5 |    5 |   6 |  23 |
| rs01@beatles.edu | Starr, Ringo     | 82.22% |    5 |    4 |   6 |  22 |
#+TBLFM: @3$3..@>$3=100*vsum($4..$>)/vsum(@2$4..@2$>);%.2f%%

I would like to write a program that takes the information in this table and generates new org files organizing each person's data separately. For example, the first new file should be ~/documents/individual-reports/harrison-gh01.org and should look something like

#+Title: George Harrison
#+Email: gh01@beatles.edu
#+Date: <2015-09-12 Sat>

* Exam Results

|               | score | possible |
|---------------+-------+----------|
| problem 1 (a) |     5 |        5 |
| problem 1 (b) |     4 |        5 |
| problem 2     |     7 |       10 |
| problem 3     |    20 |       25 |
|---------------+-------+----------|
| total         |    36 |       45 |
#+TBLFM: @>$2..@>$>=vsum(@2..@>>)

I imagine this is possible using an elisp snippet but I'm not really sure how to get started. Does anyone know how to start something like this?

Note, I'm not necessarily looking for a full solution. I'm mainly looking for commands to get me started.


texts: How can I merge/collapse multiple frames into one single frame in Spacemacs?

texts:
Sometimes I have multiple open frames (not only windows) in Spacemacs, and would like to collapse all frames into one single frame. That's easier to keep track on open buffers.

However, I cant' find a way to collapse all frames into one. I'm aware that I can kill open frames, but that's not what I want.

Question:

How can I collapse all open frames into one single frame in Spacemacs (or Emacs)?

EDIT: To clarify, what I want, please consider the following images.

What I have:

Multiple Windows appear in multiple frames.

What I WANT:

I would like to collect all windows within one frame. That is, whereas before the $n$ windows were spread across $k$ frames, now I want to have the $n$ windows within one frame.

Of course, I could delete all other frames, and then reopen the windows in my main, single, remaining frame. But I do not reopen all the windows again. Rather, I'm looking for a key binding that changes from "what I have" to "what I want"

(2nd question deleted as asked by Editor)


texts: What is the Magit 2 way to do what wazzup used to?

texts: I used to use Magit <2's wazzup mode to survey unmerged branches or general branch divergence.  What's the right way to do that or some other way to view unmerged branches in Magit 2?


texts:
I've set some variables (kept-new-versions, for one) to a higher number (10, it was 2) since I don't mind having a handful of backup files in my dir.

I did it using C-h v and customizing the variable. They get written into the .emacs file, but after restarting the program, they are at their previous values (2,2).

I have noticed the message "kept-new-versions is a variable defined in `files.el'." and I wonder, whether this is overriding my .emacs settings. Otherwise, I have no idea what it could be.

What I have in my .emacs:

 '(version-control t)     ;; Use version numbers for backups.
 '(kept-new-versions 10)  ;; Number of newest versions to keep.
 '(kept-old-versions 0)   ;; Number of oldest versions to keep.
 '(delete-old-versions t) ;; Don't ask to delete excess backup versions.
 '(backup-by-copying t)  ;; Copy all files, don't rename them.

I expect this to create a backup file after each save, but not more than 10 of them.


texts: Making scrolling easier to follow when pair programming

texts:
When pair programming with emacs I've found it is hard for the person who is not typing ("driving") to follow scrolling.  I've seen this both as the "passenger" and the "driver".

How can I make motion within the file easier to follow for other people?

I'm aware of the various smooth scrolling fixes, and I'm looking for some other visual indication here.


texts: Conditional evaluation of org mode tables?

texts:
Let's say I have a column of switches, and a column of numbers. How can I get a total of the numbers that have certain switches?

| Number | Switch |
|--------|--------|
|   1    | Yes    |
|   2    | Yes    |
|   9    | No     |
|--------|--------|
|=some formula here == 3 |


texts: How to set up Emacs to never split windows?

texts:
I want to try a new workflow where split windows only happen if I request them, otherwise Emacs simply changes windows.  I tried putting this command in my init.el:

(setq pop-up-windows nil)

And it seems to work mostly: if I use a help command, launch a compilation, use M-x occur, etc. Emacs correctly changes windows.  However, in the *compilation* buffer, if I press RET on a line, Emacs splits the frame into two windows.  Does anyone know what other configuration I need to make sure that Emacs properly switches?


texts: Automatic insertion of the parameters of a function as placeholders when auto-completing

texts:
I am kind of new to Emacs, in the sense that I never used for serious development.
I was trying to build a configuration in order to start a larger C++ project, and there is one point in particular for which I can't seem to find a solution.
For auto-completion, I am trying to use CEDET and auto-complete.
I know that by adding ac-semantic to ac-sources the auto-complete package will be able to use the tags generated by Semantic.
However, I would like to know if there is to way to:

show some kind of function documentation (e.g. prototype in C/C++) while in the auto-completion menu (and not after the text has been inserted). For example, using function-args and calling the fa-show function I am able to see some kind of documentation for the function on the point, but after it has already been inserted. The moo-complete function of this package also shows the prototype of the possible completions, but it is not "embedded" into auto-complete (it is called by a completely different function/shortcut, and I don't really like the idea of having different completion shortcuts depending on what I am doing ...). Another way that I found it to call semantic-ia-complete-symbol-menu, but the menu is particularly ugly, and I believe that something the same thing along with some kind of syntactic coloring exists.

insert placeholders for function arguments. I know that company does that pretty easily and you can then switch from on argument to another by pressing TAB (for some reason, when the said function is included from a header, it seems that this also creates a new buffer opening this header file ? But that is competely unrelated to my problem, it just seemed a bit strange of a behaviour). Is there a way to replicate this using auto-complete instead of company ? For example, using YASnippet (I've tried it, doesn't seem to work, but I am not really familiar with this package so this might the explanation) ?


texts:
Can I configure the org-todo-list to show only the most nested TODOs in a subtree?

The reasoning is to always see what's the next step on a project, without cluttering with all the parent items

For example:

# file.txt
* TODO A
* TODO B
** TODO C
** TODO D
*** DONE E
*** TODO F
*** TODO G

What shows up in org-todo-list today:

file: TODO A
file: TODO B
file: TODO C
file: TODO D
file: TODO F
file: TODO G

What I'd like to see:

file: TODO A
file: TODO C
file: TODO F
file: TODO G

Thanks in advance!


texts: How to kill all duplicates of the current frame

texts:
The command make-frame creates a duplicate frame of a given frame.
Is there a reverse command which kills all duplicates (if any) of the current frame?

More precisely assume that the current frame contains a single visible window corresponding to a visiting file. I would like to delete all similar frames (i.e., all frames with the same visiting file and a single visible window), except one of them. Assume that (global-auto-revert-mode 1) is enabled, hence all visiting files have the same content.


texts: Shell's "read" command in an elisp script

texts:
How can I get the shell's read command working (prompting for the input) in an elisp script? I have

(shell-command "read -s-p \"Enter Password: \" PASSWORD")

but it doesn't prompt anything.


texts: Can't use helm find-file action with keybinding

texts:
I have the following code that I found here (note that the buffer version works fine):
(use-package helm)
(use-package ace-window)

(defun helm-find-ace-window (file)
  "Use ‘ace-window' to select a window to display FILE."
  (ace-select-window)
  (find-file file))

(add-to-list 'helm-find-files-actions
             '("Find File in Ace window" . helm-find-ace-window)
             :append)

(defun helm-file-run-ace-window ()
  (interactive)
  (with-helm-alive-p
    (helm-exit-and-execute-action 'helm-file-ace-window)))

(define-key helm-find-files-map (kbd "M-o") #'helm-file-run-ace-window)

If I run helm-find-files and then hit TAB on a file (to open the action menu), I am able to scroll down to an entry called Find File in Ace window and hit enter. This works perfect.
Strangely though if instead of hitting TAB I use my M-o keybinding, emacs spits back to me: [No such action 'helm-file-ace-window' for this source].
I find it contradictory that I can select the action from the action menu, yet when I use a keybinding emacs says the action does not exist.
I am using Emacs 27.2 and Helm 3.6.2


texts: How to install spell-check in emacs 27.1?

texts:
I got a new laptop and installed new emacs (27.1) for windows 10. Now, I am back to the battle to get the spell check working in emacs. I am kicking myself for not saving the path to victory last time. When I followed the https://github.com/hunspell/hunspell (more than 2 years old) I stuck with an error at the "make" command during the installation:
make: *** No targets specified and no makefile found.  Stop.
Any tip will be appreciated!


texts:
I'm running org-mode 9.0.9 which I downloaded off of the official org-mode website. When I execute a shell code block I get the following error.

executing Shell code block...
org-babel-execute:shell: Wrong number of arguments: #[(session body &optional params stdin) "ÆÇ!ÆÈ!ÉÊ    \"AÉË   \"AÌ?ÍÎÏ!!@AÐr@q5ÑPc
<ÑcBc)r@qÒÓAÓÔ%,Õ
Ö\"ÍÎÏ!!CD×rCqc)rCqÒÓDÓÔ%,ØÙ!ErEqÚÛ
ÜÝF
#p#Þ .ËG[ßàáâãä HåæG!½çèG\"GqéÓIJKêLBLëìíp!!b`dMNM{JNM|*îïðñâB!Ñ\"OC\"\"PbòóQ!Óô#òRÓô#)õíp!!üìíp!!bJc)BKö÷ÑøóB;é!#K\"KKÔÓOIñKR\".ù\"\"Ñ#ËÉÊ    \"AÃÉÊ    \"AGÔVÃÆÇ!ÉÊ  \"AÉË   \"AÌ?ÍÎÏ!!STúrSqÑPc
¢ÑcBc)rSqÒÓTÓÔ%,Õ
Ö\"û
é\"+ËûFâB!\"UtÉü    \"AVWýW?sþW9ÿW9[W9\\W9]W9^W0_W0`W0aW>bW>UsÆc!XÍÎÏ!!YZdrYqUc)rYqÒÓZÓÔ%,eX!)*)" [stdin params padline shebang stdin-file script-file org-babel-temp-file "sh-script-" "sh-stdin-" assoc ...] 12 ("/usr/local/share/emacs/24.5/lisp/org/ob-sh.elc" . 4485)], 5
byte-code: End of buffer [2 times]
Org mode version 9.0.9 (9.0.9-dist @ /home/charvey/.emacs.d/org-9.0.9/lisp/)

The line that references /usr/local/share/emacs/24.5/lisp/org/ob-sh.elc is suspicious. I don't want to use the built-in version of org-mode. How can I fix this error? Is it because org-mode is using mixed code versions?


texts: Set start cursor in code window instead of speedbar

texts:
I have sr-sppedbar always turned on, but whenever I start, I have to manually click the code window to switch the cursor from speedbar to the codes. How do I start emacs with cursor in the main window instead of sr-speedbar?

Update:
It works after adding (other-window 1) to start hook in init.el.


texts: Emacs - Understand elisp syntax (mapcar '1+ '(2 4 6))

texts:
I saw this example code:

(mapcar '1+ '(2 4 6))
     ⇒ (3 5 7)

But I do not understand '1+ here. it will apply a function to a list but this style obviously not like a function. If means add, the function should be +, what does '1+ mean?


texts: On a mac, setup CMD - Shift - z to be 'undo-tree-redo'

texts:
This is not working for some reason:

(global-set-key (kbd "s-S-z") 'undo-tree-redo)

  CMD - Shift - z

While this:

(global-set-key (kbd "s-y") 'undo-tree-redo)

works.

How do I get "CMD - Shift - z" to be 'undo-tree-redo'


texts:
I like vim's tabcomplete feature - filename completion for its dropdown choices. Like this vi popdown,

I use hippie-expand with functions, try-complete-file-name-partially try-complete-file-name. It shows one option at a time not all the options with a drop-down. It consumes lot of time, calling hippie-expand for each and every wrong completion.

Is there any elisp library that has filepath autocompletion with dropdowns?


texts:
I want to change my colour scheme to a random color scheme. Consider this elisp function:

(defun random-colour-theme () ;; written 2017-04-02
  "Pick a random colour theme."
  (interactive)
  (setq randomNumber (random 2))
  (setq randomColourScheme (nth randomNumber '(
"color-theme-dark"
"color-theme-light")))
(randomColourScheme)
  )

Everything works except the last line, (randomColourScheme). randomColourScheme is a string representing either "color-theme-dark" or "color-theme-light". If the command were (color-theme-dark), then it would work. How do you execute a command that is currently in a variable as a string? I don't know how to get started on this one.


texts: org-pomodoro How can I record break times also?

texts:
How can I record the pomodoro break times in a separate heading? Every time a pomodoro ends, I would like the break to be automatically recorded under ** Breaks in my org file.
* Work
** Actual Work
:CLOCKING:
-----------------------------> pomodoro is recorded here
:END:

** Breaks
:CLOCKING:
-----------------------------> I would like to record here
:END:

org-pomodoro.el is here.


texts: Why spacemacs would like to control this computer using accessibility feature on OSX?

texts:
When I start up spacemacs it prompts for the privileged to be granted?

Why spacemacs needs to request this?


texts: How do I use Mac/OSX key bindings with Spacemacs?

texts:
I want to use Mac CMD+C for copy and CMD+V for paste in Spacemacs but I think it redefined CMD to Meta. How do I change this mapping behavior?

I found mac-key-mode but that package seems old and I don't know how to add it to Spacemacs.


texts: How to output the tangle property as comment as in org babel?

texts:
Tangling this:
#+begin_src sh :tangle /home/user/foo.txt
echo hi
#+end_src

Should become this: $ cat foo.txt
#/home/user/foo.txt
echo hi

Can I maybe lisp evaluate the org babel :comment e.g. (pseudocode):
#+begin_src sh :tangle /home/user/foo.txt :comment (eval this.tangle.property)

Seems I already asked that question How to export the tangled filename as comment?


texts: Suppose I store the current mark into a variable using mark or (mark-marker). Then I move point elsewhere and insert some text. Which function should I use to jump to the saved mark?


texts: How to preserve the visual height of the cursor after an operation?

texts:
Q: How do I find the visual line number of point (so that I can restore it after an operation)?

By “visual line number”, I'm referring to the number N of lines
between the top of the window (or the screen) and the cursor, not
the top of the buffer.

At first I thought I could calculate N with the following snippet:

(- (line-number-at (point))
   (line-number-at (window-start)))

However, to complicate things, I have sections of the buffer which are invisible.
So the snippet above usually returns values much larger than N.

Context:
I need to perform an operation that essentially erases the entire
buffer and writes it again, but I want it to be mostly invisible to
the user.

Since the buffer contents are created anew, save-excursion doesn't
help in this situation. Still, I manage to preserve point position by
saving it as a number, instead of a marker.

(let ((point (point)))
  (recreate-buffer)
  (goto-char point))

Q (alternative wording): Is there a similar method I can use to preserve the visual height of the cursor?
By that, I mean that if the cursor is initially on the Nth visible line of the screen, the window should be scrolled after the operation so that this remains true.


texts: How to immediately enable the wait cursor until an operation is finished?

texts:
When performing an operation which often takes a few seconds, how can the hourglass mouse pointer be shown immediately using Lisp?

Otherwise, the default behavior is to show the hourglass after some delay (a second by default).


texts: define-key doesn't seem to work on certain keymap

texts:
I'm trying to add some bindings to undo-tree-visualizer-mode-map. To do so I use:

(define-key undo-tree-visualizer-mode-map (kbd "S-l") 'undo-tree-visualizer-quit)

But it doesn't work, and if I do describe-keymap afterwards I see that the binding wasn't added.

There seems to be a few keymap where this behavior happens, such as ivy-occur-mode-map and Info-mode-map as well.

Any idea why is that? And how can I add bindings to those keymaps?


texts: How can I ask a user to choose from a list of options, while showing her a long list with extra metadata?

texts:
I'm writing a package which connects to a remote server for a game.

I want to show the list of players, along with their score, and let the player choose one of the players.

I thought of using completing-read, but I have no idea how to show a separate string in the list and have it turn into just the player name once the player has been chosen. For example, I will have to do some converting back and forth (i.e. turn Parham with experience 1440 to Parham (1440), and once I get the information, remove the bit with the parentheses so that I only get Parham).

I thought of using x-popup-dialog, but it doesn't seem to be suited to displaying players, which tend to be more than 50 items. The good thing is that it allows me to provide a ("title" . "value") cons cell for each item, which means I don't have to convert items back and forth.

Is there a way of providing a large list to a user, with extra metadata, and once they press enter on an item, get a unique value?


texts: clang-format-buffer with tramp doesn't actually format buffer

texts:
I'm using tramp to edit files on a remote machine, and when I run clang-format-buffer, it doesn't actually format the buffer. I get a message (clang-format: success) in the minibuffer, but the expected changes are not made in the buffer. If I use clang-format-buffer on a local copy of the file, it formats the file correctly.

What am I missing to get it to operate correctly on the buffer in emacs using tramp?

Thanks for any help.


texts: How to define "mode-specific" functions?

texts:
How can I define an Elisp function such that it is available only under a specific mode?

(FWIW, at the moment, the mode I want to restrict a function to is comint.)


texts:
I got excited about Calc's power as an embedded mode. Define some variables in natural inline notation and then do operations on them.

But the execution seems a bit messy: you got  a separate key bindings when you're in CalcEmbed mode and mistakes are easy to make.

Can the mode be tamed so that the following org-mode buffer:

* Calc test embed!

Let $foo := 342$ and $bar := 2.2$. Now $foo*bar => $!

Could be evaluated to

* Calc test embed!

Let $foo := 342$ and $bar := 2.2$. Now $foo*bar => 752.4$!

With a single key stroke, all the while remaining in org-mode?


texts: Prevent emacs from saving previous versions of text files

texts: I am editing a lot of text files in emacs and the automatic saving of previous versions is creating a massive amount of extraneous files. For example, if I edit a file called    numbers.txt    and save, then there will be a    number.txt    file as well as a   number.txt~    file. I do not need to keep previous versions. Is there something I can add to my .emacs to prevent the saving of previous file versions?


texts: Why do elisp files have end of file comments?

texts:
Why do elisp files usually end with
;;; file.el ends here?

Is there some historical reason why this was useful? I've seen it recommended in elisp style guides and I still see it in modern elisp packages.  auto-insert-mode also adds such a comment to new elisp files by default.


texts: Convert a normal key into a modifier key

texts:
I have a keyboard which, for some inexplicable reason, features a key that sends the Danish Dollar symbol to OS X - §. With shift it sends the plus/minus symbol - ±.

Is it possible within Emacs to see the § key and convert that into Hyper or Super? So if I hold down that § key and press f, it will activate H-f in Emacs.

I've tried the following, which does not work:

(define-key key-translation-map (kbd "§") (kbd "<Hyper>"))

It just says <Hyper> is undefined upon pressing the key, and doesn't act as a modifier at all.

This also doesn't work:

(define-key key-translation-map (kbd "§") "<Hyper>")

that just turns the § key into a <key.


texts: How to get p4merge like view with the ediff?

texts:
In the p4merge tool the layout for merging 2 files look like the following.

     +---------------+--------------+
     |               |              |
     |               |              |
     |               |              |
     |     a.txt     |  b.txt       |
     |               |              |
     |               |              |
     |               |              |
     +---------------+--------------+
     |   Choose any change          |
     |  from a.txt or b.txt and     |
     |  finally overwrite a.txt     |
     |                              |
     +------------------------------+

How to do this in emacs ?


texts: How to bind your keys to keymaps that aren't loaded yet?

texts:
I use use-package to manage installed packages and bind-key to assign actions to custom keys that I like.

I override most of the default Emacs keybinding (e.g. C-n becomes M-k, C-p becomes M-i), but I'm OK with other modes overriding my keybinding scheme. Sometimes, I want my keybinding persist, however. I want M-k mean something else, than in default Gnus or Helm.

However they all conflict with each other on Emacs startup, because I can't add a binding to a keymap, if it doesn't exist (because use-package sometimes defers loading of a package). E.g., the following commands throw errors (e.g. (void-variable helm-map)), because Helm and Gnus aren't yet fully loaded.

(bind-key "M-Y" 'helm-end-of-buffer helm-map)
(bind-key "M-k" 'helm-next-line helm-find-files-map)
(bind-key "M-s" 'other-window gnus-summary-mode-map)

I have all my use-package invocations in one file and bind-key for custom keybindings in another file. I don't want to put bindings into use-package calls, because maybe I want to publish my custom keybinding scheme as a standalone package. What if I want someone installing my scheme had Helm and Gnus local keybindings overriden too?

How do I manage mode-local keybindings using bind-key, so that all keys are set even if packages are loaded lately, and all key settings are inside one file?


texts: How to get ibuffer to use directory tree as filter groups

texts:
So I'm looking for some insight into how to customize my ibuffer window. I don't know much lisp but have a decent amount of emacs experience.

I tried solving it based on some google searches:
http://emacswiki.org/emacs/IbufferMode#toc10
http://www.emacswiki.org/emacs/DiredMode
and a few more links. I've tried various combinations of the tools they describe, but nothing does exactly what I want, which is roughly a combination of sorting by pathname, and filter groups. However, instead of predefined 'saved-filter-groups', I want to have filter groups based on the directory structure.

Ideally my ibuffer would display directory names as filter groups, and then sort the files alphabetically within each group. Also if possible, I would like the named directory filter groups to only display up to 3 parent directory levels

So if the buffers I have open are:

~/SomeDir/Foo/Bar/a/file_1a.js
~/SomeDir/Foo/Bar/a/file_2a.js
~/SomeDir/Foo/Bar/b/file_1b.js
~/SomeDir/Foo/Bar/b/file_2b.js

Then my ibuffer window would look like:

[ .../Foo/Bar/a ]
  file_1a.js
  file_2a.js
[ .../Foo/Bar/b ]
  file_1b.js
  file_2b.js

While I'd love a complete solution, any insight or resources you could point me towards would be nice too.


texts: js2-mode: How to avoid automatically inserting space after a function call

texts:
For example, in js2-mode, when I type the following:

console.log(

the editor outputs this (assuming the | is my cursor):

console.log (|)

Why is there a space inserted between the function and the parenthesis? How can I disable this? I have explored the options under M-x customize-group RET js2-mode, but I have not found any setting to disable this feature.

Any suggestions?


texts: add personal template directory to poly-R

texts:
I'm trying to migrate my R workflow totally to emacs (my experience with emacs is very basic), so I installed ESS and poly-markdown and poly-R among other things.
When working in rmarkdown files I wanted some personal templates I have in a personal directory to be listed along the templates offered by installed R packages (tufte, pagedown, etc.).
I couldn't find how to do it, so I ventured to add this to my .emacs file, thinking that it would add to the path to search for such templates:
(setq poly-r-rmarkdown-template-dirs "/home/my-user-here/path-to-RmdTemplates/")

When I restart emacs, and open an .Rmd file I can see the "Rmarkdown > Templates" menu, but it's not populated (completely empty). When I comment the above mentioned line in .emacs (with ;; and restart emacs), the menu is populated with the templates provided by the installed packages (tufte, pagedown, xaringan, etc.).
How can I "add" my personal directory to those where poly-R looks for templates?


texts:
I'd like to completely disable my mouse in Spacemacs. Following the advice in this answer, I set up the following in my .spacemacs file as

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration. You are free to put any user code."
  ;;(add-hook 'after-change-major-mode-hook 'fci-mode)
  (add-hook 'change-major-mode-after-body-hook 'fci-mode)
  (neotree-show)
  (with-eval-after-load FILE
    ;; don't jump the cursor around in the window on clicking
    (define-key evil-motion-state-map [down-mouse-1] 'silence)
    ;; also avoid any '<mouse-1> is undefined' when setting to 'undefined
    (define-key evil-motion-state-map [mouse-1] 'silence)
    )
  )

I see this in the Help menu that FILE

  FILE is normally a feature name, but it can also be a file name,
  in case that file does not provide any feature.

But I'm not sure what value I should use here.


texts: Setting key problem: save and close just like vim

texts:
I'm trying to use global-set-key to bind commands ":x" as save and close, just like the way vim do. Right now I'm doing:

(global-set-key (kbd "S-; x") (lambda() (kbd "C-x C-s") (kill-emacs)))

But when I type Shift+: and then x, it just write :x in the documents instead of really doing save and close. Wondering what should be the right form?


texts:
windows 10, emacs 26.1
I has file my_test.sql. This file content SQLite query. Is it possible to execute this sql query and get results?

I has sqlite db file test.db

It has table notification_invoice

I create file my_test.sql with one sql query:
select * from notification_invoice order by notificationDate

So here my steps:

Open my_test.sql

M-x sql-set-product RET sqlite

sql-product-interactive

in the sql-mode buffer) to call sql-send-buffer

As you can see I not get sql result.
What is wrong with my steps?


texts: save-excursion doesn't restore the currently visible buffer?

texts:
From the save-excursion docstring:

  Save point, mark, and current buffer; execute BODY; restore those things.

My understanding was that the restored buffer would again be visible following the evaluation of the body, but that appears not to be the case.  A basic function demonstrating the behavior that I find surprising:

(defun test-excursion ()
  (interactive)
  (save-excursion
    (find-file "just-a-test"))
  (insert "blah"))

On my system (using emacs -q; running Debian version 24.5.1) interactively running this function using M-x test-excursion I get most of the behavior I expect.  A new empty file buffer is created (there is no such file on disk) named "just-a-test" and "blah" is inserted in the scratch buffer that I happened to have open at the time.  However; the buffer that remains visible is "just-a-test" and not "*scratch*" which was (current-buffer) at the time the command was invoked.  No additional windows were created.  It is only apparent by switching back to "*scratch*" that the string was inserted as expected.

My memory may be inaccurate on this, but I recall using save-excursion when writing a function and observing the alternate behavior (the restored buffer restored as visible).  Is there any chance that this behavior has changed or that there has been a regression in 24.5.1?  I know that the definition has changed in 25.  I checked on another system (also 24.5.1) and observed the same behavior as my system.  Evaluation non-interactively (via eval-last-sexp) yields the same.  switch-buffer and save-current-buffer also yield the same.

My understanding is that each window (in the emacs sense) has a current buffer (edit: perhaps appropriately referred to simply as the "displayed buffer" and is returned by current-buffer when the window has focus) which necessarily is visible and there are no other conceptions of a "visible buffer".  If save-excursion restores the current buffer then shouldn't it be visible?

I've been scratching my head at this one for a while.  I hope someone can help me out.


texts: How to get merlin mode to work in emacs?

texts:
I try to install merlin by typing "opam install merlin" in the terminal. After the installation is done, I am asked to do this, but it doesn't seem to work. The github instruction seems to be different

(load "/Users/yxchng/.opam/system/share/emacs/site-lisp/tuareg-site-file")

(add-to-list 'load-path
"/Users/yxchng/.opam/system/share/emacs/site-lisp")
(require 'ocp-indent)

;; Add opam emacs directory to the load-path
(setq opam-share (substring (shell-command-to-string "opam config var
share 2> /dev/null") 0 -1))
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
;; Load merlin-mode
(require 'merlin)
;; Start merlin on ocaml files
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Enable auto-complete
(setq merlin-use-auto-complete-mode 'easy)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)

I added this code to .emacs but it doesn't seem to work

it gives me spurious error and says

/usr/local/Cellar/emacs/24.5/Emacs.app/Contents/MacOS/Emacs: \
/bin/bash: opam: command not found/ocamlmerlin: No such file or directory

(linebreak added to prevent scrolling)

The error is like this

How should I solve this problem?


texts: I configured Gnus to fetch mails from gmail account, and it works well, I can send and receive messages. However, one thing I'd like to improve is ability to add C-u 5 M-x gnus-group-list-all-groups command in my ~/.gnus so that I don't need to press the key combination every time I run Gnus. What should I add in config file to achieve this? Thanks.


texts:
In orgmode, it is quite useful to view the equations inline. However, sometimes this can take a while to execute. Running org-toggle-latex-fragment asynchronously would be quite useful. However, most of what I can find about async is about how to execute external commands in an async way. I did try this post (https://emacspeak.blogspot.com/2018/07/using-emacs-threads-to-execute-commands.html?m=1) and emacs-aio (https://github.com/skeeto/emacs-aio)  but it did not quite work/ I could not get it to work.

Please let me know if anyone here knows how to execute this function in an async way.

Thank you for your response!


texts: Raw v.s. Rendered - how to modify the mode for various markup languages to they render nicely, rather than as source

texts:
There are many wonderful markup languages.  For example here are some of their file extensions: nroff, md, tex, org, info, rtf, ps, html, etc. etc.  We love them all.

In most cases I visit these files with no intention of editing their content.  I'd prefer to see them rendered by the tools that handle them.

My question -  Is there a lovely solution for this.  For example, something that wraps advice around the existing modes for each of these (possibly using pandoc?).

Currently I'm slowly puzzling out how to add entries to auto-mode-alist.  This is tedious and feels quite bogus.  Some of these entries are just odd - for example (add-to-list 'auto-mode-alist '("\\.info\\'" . Info-on-current-buffer)).

For example your view of this question is rendered markdown, if you want to see it raw you can, but that's a rare desire.  For example most markup formats are displayed rendered in github, if you want the source you can hit the raw button.

My question, desire?, is has somebody already assembled an library that enhances some or all the major modes for markup languages to default to a more human oriented view?


texts: How do I select 'flag' options for magit through helm?

texts:
I'm using spacemacs with helm and magit. There are some options, for example, the ability to sort log entries in reverse order, that have a flag by them.

I don't know how to select any of these options. If I type in '-r', the flag gets selected but nothing happens. If I press enter or tab, I get an error that the key is unbound. I've looked through magit's and spacemacs' documentation, but couldn't find anything about how to actually execute these options. What is the key combination I'm supposed to press to actually use the option?


texts:
I use org mode to write notebooks for my research. I often put equation on line of their own, using M-o M-s to center the equation.

However, when I have an equation like

|a+b| ≤ |a| + |b|

the leading | character makes org enter in tabular mode. How can I disable this effect ?


texts: Why does Emacs.app (on Mac OS X) find the ctags executable inside Xcode.app?

texts:
When I try to generate a TAGS file, emacs executes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ctags, which causes problems because it is not compatible with the settings emacs uses.

I figured out how to work around the issue by modifying exec-path, but I'm still confused about why it found that path in the first place. The Xcode path was not part of exec-path prior to my modification. The Xcode path is not included in $PATH at any time that I'm aware of. As far as I can tell there aren't any symlinks involved.

I'm running Emacs 24.5 on Mac OS 10.10.3.


texts:
Is it possible to do this with vanilla emacs? If not what changes do I need to make.

Original test.html

End Result example.html

M-x html-mode
and M-x indent-region
didn't seem to help.


texts: How to specify that a package uses my key bindings

texts:
For example, I use M-s as isearch-forward:
(global-set-key (kbd "M-s") 'isearch-forward)

When I try to install isearch+ with use-package:
(use-package isearch+
 :straight t)

I get the following error:
(error "Key sequence M-s h d starts with non-prefix key M-s")"

This happens with all packages where M-s is somehow used.
How do I fix this globally so that packages respect my keybindings?


texts: In 25.1 there is (still) no builtin algorithm named filter. Why? What should I use instead? I think I've read somewhere that a standardized filter algorithm should be added to Emacs.


texts: Why is the 'type'-command not accepted in Eshell?

texts:
As I understood from the documentation of Eshell, every time that a command will be executed, it will be executed internally in Eshell/Emacs. When it gives an error code, then the command will be passed to the real shell, and the output of that command will be passed to Eshell.

So I began to wonder why the command type is not working in Eshell? In the terminal emulator, type sh gives me:

sh is /bin/sh

But in Eshell, it gives me the following:

("sh"): command not found

If the command is not found, it would be passed anyway to the real shell, right? I fail to understand why this gets stucked.


texts:
Emacs doesn't use macOS's /etc/launchd.conf env variables. I have the following there:

function addToPATH {
    case ":$PATH:" in
        *":$1:"*) :;; # already there
        *) PATH="$1:$PATH";; # or PATH="$PATH:$1"
    esac
}

export JAVA_HOME8=`/usr/libexec/java_home --version 1.8`
export JAVA_HOME9=`/usr/libexec/java_home --version 9`
export JAVA_HOME=$JAVA_HOME8
addToPATH $JAVA_HOME

But when I use getenv in Emacs to see my JAVA_HOME, it's unset. Setting it using setenv in my init file solves my issue, but this is an ugly workaround.

PS: I also set this variable in .zshenv, which I source in .bashrc, which I source in .bash_profile. So I am really confused that Emacs is not picking this up.


texts: Is it possible to set properties when entering a TODO in org-mode?

texts:
I want to achieve something similar to this where entering a TODO or WAIT state allows you take note. Instead, I want to make a PROPERTIES where the value is the heading. For example, if I have a heading called "TODO A" and if I mark it with TODO state, is it possible for org-mode to create PROPERTIES where the key is TODO_NAME and the value would be TODO A?

My main purpose of doing this is because when I have a bunch of subtasks that need to be done, I would like to see to what task those subtasks belong in the agenda view.


texts:
I'm trying to develop a new yas-snippet for expanding a common c++ log function I use a lot. The first parameter to the LOG function can be guessed by searching for existing LOG calls in the buffer. For example, if the user
types

LOG(QWERTY_ID, EVENT, DEBUG, "wooo!");
LOG<TAB>

I would like yas-snippet to expand to

LOG(QUERY_ID, UNKNOWN_EVENT, , "");

If the LOG function hasn't been used before then I would like to expand to:

LOG(<SUBSYSTEM_ID>, UNKNOWN_EVENT, , "");
    ^^^^^^^^^^^^^^

The SUBSYSTEM_ID part isn't working for me. This is what I have so far

LOG(${1:`(progn
(beginning-of-buffer)
(re-search-forward "LOG(\s*\\([A-Za-z_]+\\)\s*," (point-max) t)
(let ((m (match-string-no-properties 1)))
  (if m m ("<SUBSYSTEM_ID>"))))`}, ${2:UNKNOWN_EVENT}, ${3:$$(yas-choose-value '("DEBUG" "INFO" "WARN" "ERROR" "FATAL" "OFF"))}, ${4:""}$0);

It actually just expands to some text that it seems to have matched from within the snippet itself.


texts:
How can I disable the persistent message on an org capture buffer that says?

Capture buffer. Finish `C-c', Refile `C-w', abort `C-k'.

A similar message is displayed when entering a source block. That message can be disabled with org-edit-src-persistent-message. However I don't see such an option for capturing.

I've searched this online and used M-x apropos-documentation as well as apropos-variable with the terms capture and messageto no avail.


texts: How can I calc duration between two dates

texts:
I'd like to calculate duration time between two dates in calc.

<2017-03-21 Mon 18:45> - <2017-03-20 Mon 18:45> = 24 hr

How can I do it?

I can insert a date to calc by typing ' <2017-03-20 18:45> at calc prompt.  I can change the date format by typing dd10 to org-format.

But when I subtract <2017-03-20 Mon 18:45> from <2017-03-21 Mon 18:45>, I got 1.000035.

How can i get duration in hours and minutes?


texts: How can I exit emacs without saving any changes

texts:
I would like to be able to exit emacs without saving changes.
I might have started editing some configuration file, then decided that I don't want to save the changes.
In vi I would issue the q! command to exit the editor. I don't know if there is an emacs alternative for this.


texts: I want to type "--> " and have it automatically converted into "→ ".  Is there a way to do this using Abbrev?


texts: Configure matching settings for locate-source for helm-mini

texts:
How can I configure helm-source-locate (for helm-mini) such that it matches like the following:

Type some tex it should match some_file.tex as well as b_some_other_file.tex.


texts:
I've recently upgraded to Magit 2.10.3 and Emacs 25.2.1.

My full config is: Magit 2.10.3, Git 2.13.5 (Apple Git-94), Emacs 25.2.1, darwin.

I was previously on Magit 2.3.1 and Emacs 24.4.1.

Now, when I do a magit-status any open buffers within the project are changed to have auto-revert mode turned on.

Previously, the behaviour was only to revert buffers when Magit operations were performed (eg using Magit to checkout a different commit would revert any buffers whose files had changed). auto-revert mode was never turned on (or if it was it was only temporarily, and I didn't notice it).

Is there a way to get the old behaviour?

UPDATE #1:

Based on tarsius's answer, I've done the following:

(with-eval-after-load 'magit-autorevert
  (defalias 'magit-auto-revert-buffers 'revert-all-unmodified-buffers)
  (magit-auto-revert-mode -1))

revert-all-unmodified-buffers is something I had lying around:

(defun _revert-all-buffers (buffer-predicate)
  (dolist (buf (buffer-list))
    (with-current-buffer buf
      (when (and (buffer-file-name) (funcall buffer-predicate buf))
        (revert-buffer t t t) )))
  (message "Refreshed open files."))

(defun revert-all-unmodified-buffers ()
  "Refreshes all open unmodified buffers from their files."
  (interactive)
  (_revert-all-buffers (lambda (b) (not (buffer-modified-p b)))))

This kind of works. I guess I could change things so that I only revert buffers in the project directory.

One thing I noticed: whenever I refresh the Magit Status buffer, files get reverted. I don't really want that.

UPDATE #2

I believe I have restored the old behaviour, by turning off magit-auto-revert-mode and by doing a (defalias 'magit-auto-revert-buffers ...) that reverts buffers within the repo:

(defun _revert-all-buffers (buffer-predicate)
  (dolist (buf (buffer-list))
    (with-current-buffer buf
      (when (and (buffer-file-name) (funcall buffer-predicate buf))
        (condition-case e
            (revert-buffer t t t)
          (error
           (message "%s" e))))))
  (message "Refreshed open files."))

(defun revert-all-unmodified-buffers-in-git-repo ()
  "Refreshes all open modified buffers in current buffer's Git repo
 from their files."
  (interactive)
  (_revert-all-buffers (lambda (b)
                         (and (not (buffer-modified-p b))
                              (magit-auto-revert-repository-buffer-p b)))))

(with-eval-after-load 'magit-autorevert
  (magit-auto-revert-mode 0)
  (defalias 'magit-auto-revert-buffers
    'revert-all-unmodified-buffers-in-git-repo))

Thanks, tarsius, for pointing me in the right direction.

I wonder if something like this could be supported without having to hack things? (My concern is that my hack might break when I next update Magit.)


texts:
I use vanilla Emacs with evil. I did not install smartparens but it is present and enabled on my system as a dependency of something.

I need to rebind the M-s keys to something other than the default sp-splice-sexp.

The output of describe-key for M-s is currently:

M-s runs the command sp-splice-sexp, which is an interactive compiled
Lisp function in ‘smartparens.el’.

It is bound to M-s, <normal-state> M-s.

Going into smartparens.el, I am able to see that a smartparens-mode-map is defined and M-s belongs to it.

I have tried in vain to do:

(define-key smartparens-mode-map (kbd "M-s") nil)

or

(evil-define-key 'normal smartparens-mode-map (kbd "M-s") nil)

or

(define-key evil-normal-state-map (kbd "M-s") nil)

The list of the MELPA packages I use is:

auto-package-update atom-one-dark-theme slime
company evil column-enforce-mode paredit evil-cleverparens
highlight-parentheses key-chord

One of these packages must be loading smartparens and defining the keymap but I can't find which one.
Is there a way perhaps to see which keymap or evil keymap to change?


texts: Is there fully-automatic fill-paragraph-mode for code comments?

texts:
I'm looking for a minor mode to keep paragraphs filled at all times while typing (similar to what aggressive-indent-mode does for indentation). It also needs to be smart enough to only fill comments (and maybe strings depending on the language).

Some things that I've tried are:

auto-fill-mode automatically fills while you are typing new paragraphs but doesn't refill when you edit paragraphs.
refill-mode does constantly refill paragraphs but it tries to wrap code into paragraphs as well as comments.
I tried adding fill-paragraph to the after-change-functions hook but it screws up undo and plenty of other things (this is probably all fixable but would take some effort).

Any better ideas?


texts: How to use helm to find files that match regex in subdirectory?

texts:
I had this functionality working until I recently revamped my init files.  Now, I can't figure out how to get it back.

I use helm-find-file (mapped to C-x C-f) for finding and opening files.  I used to be able to execute the following keystrokes to find the location of a file in a sea of subdirectories.  The following shows a sample project:

~/src/Bar/Bar.cpp
~/src/Foo/Foo.cpp
~/src/FooBar/FooBar.cpp

If I executed the following, the file ~/src/Foo/Foo.cpp would open.

C-x C-f ~/src/*/Foo.cpp  <return>

If I executed the following from my home directory, helm would let me select which file to open, either ~/src/Foo/Foo.cpp or ~/src/FooBar/FooBar.cpp

C-x C-f ~/src/*/Foo*

Since I revamped my init files, I can't figure out what setting I nixed.  Can anyone point me in the right direction of how to acheive this functionality again?


texts:
My initialization file is organized in org-mode with src snippets. Is there a way I can profile it to see which snippets take the most time to evaluate? When my initialization file was in Elisp, I was able to profile it with ProfileDotEmacs, but that doesn't work for me anymore.

Here is how I load the Org file:

(org-babel-load-file "path/to/main.org")

Since the snippets are evaluated with Babel, maybe there's a way to tell Babel to output the execution time of each snippet?


texts: How do I pass all the output of process to a function?

texts:
I want to call a command asynchronously, and define a function that handles output from that command. I don't want to simply write output to a buffer.

According to the Elisp info (36.9.2 Process Filter Functions) I need to set a process filter function. I tried this:

(defun my-echo-filter (proc string)
  (message "proc: %s string: %s" proc string))

(let ((my-proc (start-file-process "foo" nil "date")))
  (set-process-filter my-proc #'my-echo-filter)) ; writes the time to *Messages*

However, this makes me nervous. I'm starting the process first, and only afterwards am I attaching the process filter.

If I do anything between creating the process and attaching the process filter, I can miss output.

(let ((my-proc (start-file-process "foo" nil "date")))
  (sleep-for 2)
  (set-process-filter my-proc #'my-echo-filter)) ; Does not write the time!

How do I create a process and ensure that my process filter doesn't miss anything?


texts:
I expected the outcome of the following small program:

(progn
  (setq x 1)
  (case x
    (x 'Yes)
    (t 'No)))

to be Yes, given that case compares things with eql, and surely x is eql to itself.  However the outcome is No and I am completely puzzzled by this!

This is a long comment, not an answer!

Thanks to everybody for making everything perfectly clear.    My original intention was to use 'case' to simulate something like

(cond
  ((equal x a) 'this)
  ((equal x b) 'that)
  ((equal x c) 'something-else))

which would look much cleaner if it were equivalent to

(case x
  (a 'this)
  (b 'that)
  (c 'something-else))

But, alas, I understand that these are not equivalent forms due to the fact that case evaluates x but does not evaluates the keys in each clause.

I thought of faking things, such as in

(let ( (x 2) (a 1) (b 2) (c 3) ) (flet ( (eql (x y) (equal x (eval y))) )
  (case x
    (a 'this)
    (b 'that)
    (c 'something-else))
))

which does work as I'd like but I suppose it is a bit blasphemous to alter the meaning of something as basic as 'eql', even if only temporarily!


texts: How to open Emacs 24.5 maximized from terminal in OSX?

texts:
So far I have only used Emacs on Ubuntu. So it was time for a change, and on my new MacBook Pro, I installed Emacs 24.5 from http://emacsformacosx.com/

Now, when I go to the terminal window and type

$ /Applications/Emacs.app/Contents/MacOS/Emacs -mm

Emacs does not open maximized. What am I missing here? (I have not created any Emacs init file yet)


texts: What are the lsp-mode equivalents for "tide-rename-file" and "tide-project-errors"?

texts:
I recently moved from tide-mode to lsp-mode for TypeScript development and I'm struggling to find some equivalent functionality:

M-x tide-project-errors: Similar to tsc --noEmit, opens a buffer that shows all errors present in the workspace. M-x lsp-treemacs-errors-list is the closest, but ignores files that aren't currently open in buffers. (I use this especially useful when I modify a type and want to find all places that need to be changed as a consequence.)

M-x tide-rename-file: Renames the current file and updates all other files that import it. There seems to be some code for this but I can't see a path to a user command.

I'm using theia-ide/typescript-language-server, but javascript-typescript-langserver doesn't seem to make a difference.


texts:
From the documentation of string-width string:

  This function returns the width in columns of the string string, if it were displayed in the current buffer and the selected window.

For me this imply that (string-width "1\n12\n123") should return 3, while in reality it returns 6.

I can accept this (even though in my opinion this behavior contradicts documentation), but I also would like to know if there is an easy way to find

  the width in columns of the string string, if it were displayed in the current buffer and the selected window.

I can imagine implementation when I first split string with \n, then find string-width for each piece and take maximum, but, somehow, I don't like this solution very much.


texts:
I've been trying out spacemacs for a while and it looks pretty good.

I've got a problem, since I don't remember all the different commands after you press SPC, i keep having to look them up. When I do press SPC, i only get the following options.

I found the second picture from http://codingwithaxe.com/from-vim-to-emacs-with-help-of-spacemacs/ but I'm not sure how they were able to do it.

I'm on windows8 and haven't made any changes to any configuration files.


texts:
Emacs noob here, I want to use melpa-stable whenever possible for my packages.

use-package has an option for this, use-package-always-pin.

  By default package.el prefers melpa over melpa-stable due to the versioning (> evil-20141208.623 evil-1.0.9), so even if you are tracking only a single package from melpa, you will need to tag all the non-melpa packages with the appropriate archive. If this really annoys you, then you can set use-package-always-pin to set a default.

How am I supposed to set this?

The documentation for the variable is:

use-package-always-pin is a variable defined in `use-package.el'.
Its value is nil

Documentation:
Treat every package as though it had specified `:pin SYM.

You can customize this variable.

Since you would :pin like this

(use-package smooth-scrolling
  :pin melpa-stable)

I would assume that it would one of these

(setq use-package-always-pin melpa-stable)
(setq use-package-always-pin 'melpa-stable)

but either one (tried separately) gets me the error:

Symbol's value as variable is void: melpa-stable

If I start emacs and then eval (setq use-package-always-pin 'melpa-stable) it seems to work as expected. I would guess it was some kind of load order issue, but I'm pretty clueless about how that works.

I tried:

(with-eval-after-load 'use-package
  (setq use-package-always-pin 'melpa-stable))

No luck.


texts: How to run a previous command in an Emacs shell?

texts:
Of course when I am in Terminal and I press the up arrow key, it goes to the previous command. However, when I hit the M-x keys and type shell an integrated shell comes up in Emacs:

However, if I type a command and press up, this happens:

How do I get back to the last command I typed?