texts: How to wrap / intercept commands bound to a given key?

texts:
I am trying to have a global override for a binding, where I am checking for some specific conditions to hold.  If they don't, I would like that binding to do whatever it was going to without my intercept.  I.e., something like the following:
(global-set-key <existing-binding> 'foo-wrapper)
(defun foo-wrapper ()
  (interactive)
  (if my-condition-holds #'my-foo <whatever existing-binding would have otherwise done here>)))) ;;

How can I programmatically delegate to <whatever existing-binding would have otherwise done here>?
Please note: I am looking to not hard-code any commands into the wrapper that are not part of my custom logic. I'm looking at keybindings that are frequently overridden in various mode maps, and it seems impractical to have to manually figure out which command to dispatch.
Edited to add: concrete example is special handling of parentheses. In this case, <existing-binding> is simply (kbd "("), and my-condition could be something like (and current-prefix-arg (eq major-mode 'foo-mode)). Crucially, if my-condition does not hold, I need to delegate to the  default behavior, which is highly context-specific: it may be handled by paredit, or smartparens, or evil, or be a self-insert-command.


texts:
I have an org-mode document that looks like this

* Total Score

** First Part [2/3] * 4
- [X] Item 1
- [X] Item 2
- [ ] Item 3

** Second Part [2/3] * 3
- [X] Item 1
- [ ] Item 2
- [X] Item 3

Is there a way I can multiply the number of checked items in each headline by a number and accumulate the result on the parent headline?

* Total Score [14/21]

** First Part [2/3] * 4
- [X] Item 1
- [X] Item 2
- [ ] Item 3

** Second Part [2/3] * 3
- [X] Item 1
- [ ] Item 2
- [X] Item 3

If that's not possible, is there a way I can use these counts of checked-items as numbers in an org-table?


texts:
I've been playing with vc-git-grep as pointed to by this answer
How do you grep from within emacs ( git grep 'foo' | grep baa )

I have a special requirement like this:

$ git grep -e 'include' --and -e Image

components/core/app/models/contact.rb:  include HasImage
components/core/app/models/opportunity.rb:  include HasBannerImage
components/core/app/models/organization.rb:  include HasImage
components/core/app/models/organization.rb:  include HasBannerImage
$

Is it possible to do that with emacs vc-git-grep ?

I tried

-*- mode: grep; default-directory: "~/" -*-
Grep started at Wed Sep  6 06:59:56

git --no-pager grep -n -e Image -- *
Gemfile.lock:70:      rails-assets-Imagesloaded (= 4.1.1)
Gemfile.lock:362:    rails-assets-Imagesloaded (4.1.1)
...

To summarize, my question is, is it possible to manipulate the parameters passed to the git grep command?


texts: How do I build emacs from sources on macOS Catalina Version 10.15.4

texts:
I typically run gnuemacs using MacPorts. However, I have a friend who does not have admin on his managed mac, so I want to build for him a full release of emacs that will run out of his home directory. He does not have admin rights.

I tried downloading the sources for all of these versions:

-rw-r--r--  1 xf  staff  20403483 Feb 17  2005 emacs-21.4a.tar.gz
-rw-r--r--  1 xf  staff  39587396 Sep  5  2008 emacs-22.3.tar.gz
-rw-r--r--  1 xf  staff  47721193 Jan 28  2012 emacs-23.4.tar.gz
-rw-r--r--  1 xf  staff  39759804 Apr 10  2015 emacs-24.5.tar.xz
-rw-r--r--  1 xf  staff  44415140 Aug 28  2019 emacs-26.3.tar.xz

None of them build properly. I always end up with some kind of Killed error, like:

emacs-26.3 % make
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C lib all
make[1]: Nothing to be done for `all'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C lib-src all
make[1]: Nothing to be done for `all'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src VCSWITNESS='' all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ../admin/charsets all
make[2]: Nothing to be done for `all'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ../admin/unidata charscript.el
make[2]: Nothing to be done for `charscript.el'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ../admin/unidata all EMACS="../../src/bootstrap-emacs"
  ELC      uvs.elc
/bin/sh: line 1: 37172 Killed: 9               "../../src/bootstrap-emacs" -batch --no-site-file --no-site-lisp -f batch-byte-compile uvs.el
make[2]: *** [uvs.elc] Error 137
make[1]: *** [../lisp/international/charprop.el] Error 2
make: *** [src] Error 2
emacs-26.3 %

So I tried using brew. It built emacs, but I get the same problem:

% brew/bin/emacs
zsh: killed     brew/bin/emacs %

So what's the proper way to build this?


texts: Find/replace in differrent file extensions

texts:
Windows 10, Emacs 25.1, Dired+, xah-find

I use package xah-find for find/replace text in many files.
OK. It's work.
If I want to find in all java files I use the next regexp:

File path regex: \.java\'

OK. It's work.
But if I want in files with the next extensions:

 .java, .xml, .properties

What regexp must be?
'


texts:
At the weekend I wiped my dotfiles and replaced them with prelude. I do most of my work in C#, so I've got csharp-mode installed.

Typing in c# is laggy, in a painful bursty way. A few words come out smoothly, then there's a big pause over the next few words. There's no problem with moving the cursor around or scrolling the buffer.

I've tried turning off minor modes on a buffer and continuing to type. I've disabled the following with no change to the problem:
 - projectile-mode
 - company-mode
 - guru-mode (think this is a prelude thing?)
 - flycheck-mode

My mode line says I've got C#/l, MRev, Helm, SP, Pre and Abbrev still running. They all seem pretty important.

There's nothing in the messages buffer when these pauses occur.

I'm using emacs 24.4.

Is there any keystroke profiling I can turn on, to see what's slowing things down?


texts:
With Emacs' doc-view-mode I can easily shrink/zoom/etc PDFs, however, I would like to be able to do the same thing with images. Currently when I open an image I cannot adjust the zoom level to fit it to the frame. I know there is image-mode-fit-frame, however, it does not help when the image is larger than my screen.

Is there a package or mode that will allow me zoom in and out on an image?


texts:
How to write a function for finding all files in a directory which not ending with pyc and pyo?
I've tried something like (find-lisp-find-files root "^(?!.*pyc$).*$") but it does not return any possible result.


texts:
Windows 10, Emacs 25.1

In my init.el I set:

delete-by-moving-to-trash t

So as result when I delete file it move to trash.
Nice.
But how I restore delete file from trash by Emacs?


texts:
I'm trying a new custom theme, but it only seems to be partly applied as the background isn't appearing. I'm very, very new to Emacs, so would appreciate advice on how to fix it.

I'm using GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.9) of 2015-03-21 on kissel, modified by Debian. Ubuntu 15.04 Called from the GUI, not the terminal. I'm also using the most recent version of Emacs live

My init.el is here


texts: I installed the magit package via Marmalade. When I run M-x magit-status it takes a long time to run and complete (about 30 seconds). How can I speed this up?


texts: How to open a file from Windows explorer in Cygwin Emacs

texts:
I currently have Cygwin Emacs installed on my Windows machine.  I am wondering:

Is there a way to open files from Windows Explorer in Emacs (which would be running in terminal mode in Cygwin).

The default is always notepad or all the GUI applications on Windows and I would like to be able to open Cygwin and Emacs and then open the file directly.

On some GUI type editors you can just drag and drop a file into the editor.  This obviously doesn't work with Cygwin Emacs.

It seems like there is no .exe file for Cygwin Emacs which means I can't point anything to the binary and indicate "open file with"...


texts:
Is there an Emacs mode for GitHub Flavored Markdown?

GitHub Flavored Markdown adds a number of features to traditional Markdown: underscore handling, url autolinking, strikethrough, and tables. It would be nice to have an Emacs mode that supports these additions (particularly tables).


texts: Warning (yasnippet): modified buffer in a backquote expression

texts:
When I use yasnippet, I keep getting this error:

Warning (yasnippet): `foo-snippet' modified buffer in a backquote expression.
To hide this warning, add (yasnippet backquote-change) to `warning-suppress-types'.

I added this line to my config:

(setq warning-suppress-types (quote ((\(yasnippet\ backquote-change\)))))

But it doesn't seem to have worked.


texts:
Problems with my modeline separator aren't quite the "Ugly separators" problem as seen here. But the color is slightly off, as in this screenshot.

I can solve it with this piece of code. But then everything just looks more drab.

(setq ns-use-srgb-colorspace nil)

Is there a way of fixing the modeline color skew while keeping a full color pallette (or srgb-colorspace)? This is the color balance I expect to have.


texts:
I have the following in .bashrc.

export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -t"

When I run, for example

emacsclient something.tex &

when running X, in a Konsole terminal (Konsole is the KDE X term client), the file opens up inside the Konsole terminal displaying the file (as though I had called -nw), when it should start up an emacs X frame. Also, the file is not normally editable. I cannot type, and when  enter it behaves like I am still in the terminal, except the cursor jumps around on the screen when I try to type, and echo $TERM still gives xterm. Also, I'm seeing stuff like Auto-saving...done at the bottom of the terminal. Checking the processes gives

$ ps aux | grep emacs
faheem   31260  0.0  0.0  12516   800 pts/2    S    17:40   0:00 emacsclient something.tex
faheem   31269  0.2  0.1 230896 27408 ?        Ss   17:40   0:01 emacs --daemon

After further investigation, it seems the backgrouding &. Is causing the problem. Leaving it out causes emacs to open in -nw mode. But I want a full X emacs frame. Why is it not doing that?

I see the -c option says

-c, --create-frame
          create a new frame instead of trying to use the current Emacs frame

and this does create a emacs X frame, but if there is no existing frame, why doesn't it create one instead of opening in the terminal?


texts: How do I search Info for help on a given keyword or function?

texts:
Occasionally looking up a function with C-h f will cross reference to an Info node in the manual, but that is pretty rare. I often want a way to jump from the help documentation on a given function to the corresponding documentation referencing it in Info, but I have yet to find an easy way to do that. info-finder can sort of work on categories, and of course it's possible to manually search through various Info manuals from the root menu at C-h i.

I have found info-apropos, which can be a little slow. It appears to read and index every Info file for every keyword search. Is there a better or faster method for looking up a keyword in Info? Is there a way to pre-index info-apropos? Is there a nice way to jump from the help for a function to related Info pages?


texts: What is the usefulness of `exchange-point-and-mark`?

texts:
The exchange-point-and-mark command is bound to C-x C-x, but I cannot think of any use cases that would make it deserving of such a prominent binding.

How can I use the exchange-point-and-mark to improve my editing technique?


texts:
Sadly, my Emacs is too old (and not mine to upgrade) and so I can't run markdown-mode.  I'd like to set a buffer to fill mode when I open an .md file.

Is there a simple way to do this?  The whole add a hook approach seems like overkill, but maybe it's the only way?


texts:
Is it possible to set the colour or font of markers (e.g. the ones set by gud in gud-display-line by using make-marker). The theme I am using shows markers in a difficult-to-see light gray. I would prefer something very obvious (e.g. red) and potentially also slightly larger.

There is no  information on setting or modifying colour/size in the gnu elisp manual. I'm not sure how this should work.

note: I am using spacemacs. The questions I believe is not specific to spacemacs, but I would also welcome an easy setting for doing this in spacemacs.


texts: In exwm (Emacs X Window Manager) how can I switch to the workspace where a given app resides?

texts: I'm using exwm-workspace-switch-to-buffer to find already opened applications. My problem is, say I'm in workspace 1, and Firefox is open in workspace 3, if I call exwm-workspace-switch-to-buffer for Firefox, exwm brings Firefox to workspace 1 but I want it to shoot me to workspace 3 where Firefox resides and leave the workspace 1 intact. In i3wm I can do this by something like for_window [class="(?i)firefox"] focus


texts:
Given '(a b c d), how would I remove b and c to end up with '(a d)?  Is there a "right" way to remove multiple, distinct elements from a list?

Obviously, one could do (delete 'c (delete 'b '(a b c d))). But this doesn't generalize or scale well1.

Other possibilities include:

Create a predicate function and map it over the list with something like delete-if-not.
Perform a set difference (if that's even different from the list mapping)

I am getting lost in all the different implementations which accomplish, so it seems, the same thing (i.e. delete, dash, seq, cl-delete, etc.).

I would prefer to only use whatever ships with vanilla Emacs (26.3), unless there is a compelling reason to introduce an external dependency.

1 I understand the distinction between remove and delete in that one preserves the original list while the other does not.  It's my impression that the two are more or less interchangeable otherwise.


texts: How to check in elisp if a string is a substring of another string?

texts:
How to check if a string s1 is a substring of another string s2?

For example (test-substring "f t" "df tj")  --> t,
(test-substring "ft" "df tj")  --> nil.


texts: bashrc script to automatically create emacs server session on startup?

texts: I want to have .bashrc check to see if an emacs server is currently running, and if not, start one. I know how to start the server but I am not sure how to check whether it is already running - should I just grep the processes for Emacs? Curious if anyone has something like this set up.


texts: Programmatically insert files into Dired buffer

texts:
I have a list of file names (with full path) and I want to create a Dired buffer listing this set of files. How would I go about doing that?

How do I create a Dired buffer from a list of file names?

Without using external dependencies.


texts: how to call `org-attach` from a function?

texts:
I would like to write a function that attaches files using org-attach. Unfortunately, org-attach only seems designed to launch a "menu", and not to be used programmatically. Since it does not accept arguments, I can't just do:
(defun attempt1 ()
  (interactive)
  (org-attach "testfile.txt"))

I looked through the org-attach.el source and found a org-attach-attach function, which allows me to do:
(defun attempt2 ()
  (interactive)
  (org-attach-attach "testfile.txt"))

This works but only after I have called org-attach at least once interactively.
How can I feed a file name to org-attach inside a function? Alternatively, how can I make sure that org-attach-attach is available at startup in a "fresh" emacs session, without manually calling org-attach first?


texts: Avoid "`timestamp-wrapper`" span around timestamps when exporting org to markdown

texts:
Version info:

Emacs: 26.3
Org: 9.1.9

Am trying to export org notes to markdown format for publishing. Am using the org-gfm-export-as-markdown to preview the markdown that will be generated. Later I will wrap this in a script so I can do bulk export.

However am having a tough time finding an option that will export the timestamps as normal text and not surround it with the

Please find the image as an example:

I would like the timestamp line to look something like this in markdown:

## [2018-11-14 Wed]: #journal:

P.S.: I tried pandoc but I had other issues with it. The [ in the timestamp was exported as \[. For eg: ## \[2018-11-14 Wed\]: \#journal: @EmacsExport


texts: How can I stop the enter key from triggering a completion in company mode?

texts: I often want to go to a newline while the company mode suggestion is showing. How can I set up company mode so only the tab key triggers a completion?


texts:
When using magit on a local file, I stage my changes and
I then press c and c again to commit. I get a new window showing the diff and a window for the commit message. I write my commit message press C-c C-c and the diff and commit window close.

However when using magit on a remote file using tramp, if I stage a change then press c and c again to commit, I only get a new window for the commit message not the diff window. I can write the commit message as normal,  but not being able to see the diff at this point is annoying.

One thing I noticed is that if I do not stage my changes when using magit on tramp and I go to commit, I DO get a diff window, with the message in the message buffer "Nothing staged. Stage and commit all unstaged changes?(Y or n)" I can then then type Y to make the commit. But this way is only allowing me to see a diff for all changes to be placed in one commit, rather than the bits I want to stage for a commit.

How can I get magit to open the diff window when the commit message window is opened on a remote file using tramp?


texts: Org mode capture template for repeat tasks

texts:
I want to capture several tasks that will repeat annually from the date on which they are captured.
So, I did:
(setq org-capture-templates
    '(("a" "TODO Item that repeats annually" entry (file+headline "~/Documents/todo.org" "Annual")
       "* TODO %?\n SCHEDULED: %t")))

This adds a TODO with scheduled date as today. How do I get +1y added to scheduled?
On a more general note, what should the capture template be with schedule for tomorrow, tomorrow recurring annually, etc.?


texts: Is there a helm read-from-minibuffer functionality?

texts:
I have an interactive command which uses read-from-minibuffer with a history variable.

What I now would like to have is a helm function that provides a simmilar operation: enlisting history candidates in typical helm manner and using what I typed, if there is no match, adding that to the history variable.

The "what I typed" part reminds me of helm-find-files, where I can select existing files and optionally create a new one.

I'm asking this to be shure that I did not overlook an existion approach, before I start to implement it on my own.


texts: Org-mode: Limit the number of tasks to which a tag can be applied

texts:
I have an idea where I have something like a FOCUS tag that I can apply to tasks that need special attention.

However, I want to make it so that only 3 tasks can actually be tagged with FOCUS at a time. If I try to tag a fourth with FOCUS, I should just get an error. So in order to apply a FOCUS tag, the count of currently FOCUS-tagged tasks should be <3, otherwise I'll have to untag one.

Any idea on how to get started on doing this?


texts: How can I prevent company-mode completing numbers?

texts:
In org-mode, when I type some numbers, company always pops up the number completion like:

  20 20001   -----------1200111 ----------2

These numbers come from my org-mode files.

I would like to turn off company number completion. How can I do this?


texts: Want to select asterisk buffers after killing the current buffer

texts:
I am facing the question about the buffer selected after killing the current buffer.

When I kill the current buffer, the recent file buffer is selected ignoring asterisk buffers. Unless there are no file buffers, an asterisk buffer is not selected. But when I tested on default emacs (invoked by emacs -q), an asterisk buffer can be selected similarly to a file buffer after killing. I want to select asterisk buffers in the same way as file buffers after killing.

I think some packages I installed affect this, so do you have some ideas on what packages stop it from selecting asterisk buffers.


texts: Auctex: Fold all environments of a specific type in a buffer

texts:
With auctex I can run TeX-fold-env the environment on which point currently is located.

How can I fold all environments foo (\begin{foo}... \end{foo}) in my buffer at once? And how to unfold all occurences of foo?


texts: c-set-style: Error loading guessed style

texts:
My company has very specific indentation rules for C code. I want to create a style from those rules, and have it load at startup.
Doing a C/Guess Style From This Buffer and C/Install Last Guessed Style works great. It indents properly. But it goes away when I exit Emacs, and I have to guess and install the style again.
So I a did a C/View Last Guessed Style. I get a buffer with a very long lisp expression (78 lines) starting with
(c-add-style "STYLE NAME HERE"
             '("style-name-I-installed-interactively"
               (c-basic-offset . 3)     ; Guessed value
               (c-offsets-alist
                (arglist-cont . 0)      ; Guessed value
                (arglist-intro . ++)    ; Guessed value

I was a little confused why it asked me to enter a style name when I already did, and it listed it in the lisp (as I show above), but I changed the style name to what I wanted, which was identical to style-name-I-installed-interactively.
When I evaluate this buffer, everything is fine, but when I go to set the style (C-c .), I see
c-get-style-variables: Variable binding depth exceeds max-specpdl-size


texts: permanently change buffer mode of a file?

texts:
Beginner question:

In OSX 10.6.8, Aquamacs has many buffer modes. My .tex files open in TeX mode, but I would like to open them in LaTeX mode. I can change the Mode with "Change Buffer Mode", but even after a "save" or a "save as", the old mode remains.

How can I change the mode once for all? (The question also pertains to standard emacs, I guess).


texts: elpy autocomplete stops working unexpectedly

texts:
I've configure emacs to write python code and I love it!:). It works very well but after some situations that I cannot understand the autocomplete stops working on all buffers. If I restart emacs it works again.
Sorry for the vague question but maybe some emacs expert can figure it out by looking at my init.el file.
Thanks in advance! :)

;; 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)

(require 'doom-themes)

;; Global settings (defaults)
(setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
      doom-themes-enable-italic t) ; if nil, italics is universally disabled

;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
;; may have their own settings.
(load-theme 'doom-one t)

;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)

;; Enable custom neotree theme (all-the-icons must be installed!)
;;(doom-themes-neotree-config)

(setq ring-bell-function 'ignore)
(fset 'yes-or-no-p 'y-or-n-p)
(electric-pair-mode 1)

;;(set-background-color "#635050")
;;(set-foreground-color "cornsilk1")
(set-face-attribute 'default nil :height 150)
(tool-bar-mode -1)
(global-linum-mode t)

(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

(setq mac-right-option-modifier nil)
(setq mac-command-modifier 'control)

(show-paren-mode 1)

(setq electric-pair-pairs
      '(
        (?\' . ?\')
        (?\{ . ?\})

    )
)

(desktop-save-mode 1)

(add-hook 'python-mode-hook 'highlight-indent-guides-mode)

(require 'neotree)
(global-set-key [f8] 'neotree-toggle)

(setq default-directory "~/")

(setq elpy-rpc-python-command "/Users/marco/emacspython/bin/python2.7")
(elpy-enable)
;;(add-hook 'after-init-hook 'global-company-mode)

(require 'pyvenv)
(pyvenv-activate "/Users/marco/emacspython")

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/") ; many packages won't show if using stable
  ;; '("melpa" . "http://melpa.milkbox.net/packages/")
   t))

(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.
 '(exec-path
   (quote
    ("/Users/marco/emacspython/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9" "/Applications/Emacs.app/Contents/MacOS/libexec" "/Applications/Emacs.app/Contents/MacOS/bin" "/usr/local/bin/")))
 '(package-selected-packages
   (quote
    (doom-themes magit pyenv-mode neotree elpy highlight-indent-guides))))
(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.
 )


texts:
I am trying to go deeper with org mode to the literate coding stuff itself rather than merely for markup.

I am writing a document where I'm solving some coding challenge, and part way through reasoning about it, decide to take an aside to ensure that I know how to pass tables into src blocks and to use sessions. The next section of my document is a sort of "aside" where I am testing just that (though using some of the named tables in the containing header). I then want to return to solving the problem.

So I have

* My problem
  writing
  src block
  writing
  a-named-table
  more writing

  here's my aside, writing
  src block
  writing
  src
  writing
  src

  writing, back to the main thing, I'm not referencing anything in the aside here

What is a good way of denoting that aside so that I can expand/collapse it and control whether I want it exported or not later?

I could use a headline but then returning to the main code would require its own headline which would be weird in the outline as it would split up what is one logical flow of thought into two simply because an aside was nestled between.

I use asides in writing prose a lot so I think it would probably be beneficial for my literate coding efforts to know the "right" way of doing it.


texts: Bolnagri (Devanagiri/Hindi) Input method

texts:
There is a particular input method for Hindi language (or Devanagiri script), known as Bolnagri. It is very convenient to type using this method and it comes by default on Ubuntu.

However, in Emacs, there are 4 input methods for typing in Devanagiri, but none of them is Bolnagri. That is when I press C-x RET C-\, I don't see any "Bolnagri" in the options.

How can I get this Bolnagri input method to work in Emacs?


texts: "Invalid base64 data" error when using tramp

texts: I'm using an Intel Edison, and I want to edit files on there with Emacs.  I can connect to the device with tramp, using several methods and explore using dired.  But trying to visit a file gives an error "Invalid base64 data".


texts: Tramp Ipython remote session: Problems with remote paths within code

texts:
Here's my setup:

* Tramp on remote
:PROPERTIES:
:header-args: :dir /ssh:me@server.com|ssh:me@remote:/project/
:END:

#+BEGIN_SRC ipython :session :results output drawer
import pandas as pd
data = pd.read_csv('/project/path/to/file/data.txt')
#+END_SRC

When I run the code, tramp complains that the file '/project/path/to/file/data.txt' does not exist.

  FileNotFoundError: [Errno 2] No such file or directory:

However, the file does exist on the remote, and if I switch to the org-babel session and type in the commands directly, then I don't get any errors.

Does anyone know what could be happening here?


texts:
Question

Does a "lazy" or "asynchronous" vc mode exist?

Background

Emacs vc mode is designed on the assumption that the version control backend is fast. Much of the core vc features wants the version control status information immediately. For example, vc-refresh-state is run from find-file-hooks, which sets up buffer local state with respect to the vc backend, synchronously.

There are places that do issue commands asynchronously. E.g. I do see vc-do-async-command, and it is called for some operations, just not the ones that matter most to me (e.g. from find-file-hooks).

My negative experience

This is a problem on slow file systems or if the version control system is not fast. For example, with global-auto-revert-mode on, in a large Mercurial client, where any given hg status takes 0.3 seconds, changing the current branch can take quite a long time if I have a lot of buffers open.

If I disable vc mode with something like vc-ignore-dir-regexp I lose all vc commands. I would gladly give up small niceties like up-to-date version control information in the mode line, if it got me performance.

Lazy approach

A "lazy" vc mode might delay all interaction with the version control system until the user explicitly interacts with a vc command. Commands such as vc-diff would first determine the vc backend, if needed, and then do the operation. This would be functional equivalent of having no vc mode at all, and simply switching to a shell and running commands like foo diff, except that it would still have the nice Emacs veneer. In some respects, this might end up being a "vc mode lite".

Asynchronous approach

An "asynchronous" vc mode would be more delicate to design and implement, but essentially run all external commands on an asynchronous queue. This way, a large number of files could be auto reverted without blocking Emacs.


texts: Why does multiple-cursors use the same char for all cursors with iy-go-to-char, but not with zap-up-to-char?

texts:
Both iy-go-to-char and zap-up-to-char take a prefix argument and a character argument prompted for in the minibuffer. Both functions seems to implement this by using (interactive "p\ncPrompt string: "). But they behave very differently in multiple-cursors-mode: iy-go-to-char only prompts once for the character and uses that same one for every cursor; zap-up-to-char prompts for a character for each cursor.

I'd like to know why multiple-cursors treats them differently, but above all I'd like to have them both behave as iy-go-to-char does: single prompt, reuse that character for all cursors.


texts: Get Company to show suggestions for Yasnippet names

texts:
I use the packages Company mode and Yasnippet.  When I'm typing in a buffer, I get autocompletion suggestions from Company.

For Yasnippet, I have a directory which contains the snippets. In that directory I have for example, the file foo.yasnippet.

When I'm typing foo in the buffer, and press Tab, I get a popup menu for yasnippets, which I chan choose which snippet (foo or foo-bar) I want to insert.
I would like to integrate the yasnippet foo in Company completion. When I type foo, then I would like to see the snippet in Company completion popup.

Is this possible? If so, how could I achieve this?
In Vim you have that with Neocomplete and VimSnippets. When I googled around, I found this link with Elisp but I couldn't wrap my head around how to apply it.

Any suggestions?


texts:
I am currently using Zenburn.  My .emacs file contains

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))

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

I want to use tomorrow-night-bright.  So, I placed the tomorrow-night-bright.el file in the same folder with zenburn.el.  When I try

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))

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

Emacs says it can't find the file/folder.  When I use M-x customize-themes, it has it listed, but again can't find it when I try to execute it.


texts: How can I disable indentation rules within docstrings in python-mode?

texts:
When writing within docstrings in python-mode, I'm only able to tab/indent deeper than the leading edge of the string. For example:

def foo():
    """
|   | << the only places I can "tab" to.
    """
    pass

I'd like to be able to tab deeper within docstrings, to make editing easier for editing documentation, working with YAML, etc.

Is there any way I can advise python-mode to ignore indentation rules within docstrings?


texts: Insert mode: make C-a insert previously inserted text

texts:
In Vim, Ctrl-A can be used in Insert-mode to insert previously inserted text, much as the "dot" (.) command can be used in Normal-mode. For context and a demonstration, watch from ~2m25s - 5m08s in George Brocklehurst's ThoughtBot talk, "Let Vim Do the Typing", or read the excerpt I've transcribed below.

  There is a special register
  called "dot". The "dot" register contains whatever the last text you
  inserted was, the last time you were in Insert-mode. The last time
  I was in Insert-mode, I inserted "Hello<space>world<newline>", so if I
  go back into Insert-mode and I hit Ctrl-R, and then I hit ., I
  reinsert that entire thing. But even cooler, if I just hit Ctrl-A,
  Vim just does that for me.

My question is: how can I obtain this functionality in Evil mode?

With the default settings, entering C-a while in the Insert state of Evil mode just moves my cursor to the beginning of the line.

I tried adding

(define-key evil-insert-state-map "\C-a" 'evil-repeat)

to my .emacs file after the call to Evil, but this does not behave quite as expected: on the first invocation after entering the Insert state, it inserts whatever character was previously used to enter the Insert state (e.g. i or I or o or suchlike), and then inserts the expected text. On subsequent invocations, it does not appear to do anything.


texts: Changing current math mode (e.g. inline to display)

texts:
Is there a built-in or at least ready-made way to change which math mode I'm in? For example if I'm writing in inline math mode (which in my case would mean my cursor is between single dollar signs) and I want to switch to display math mode (which in my case would mean said dollar signs get changed to \begin{displaymath} and \end{displaymath}), I'd like to be able to do so with some quick keystrokes.

I'm thinking about something akin to the C-u C-c C-e command. Perhaps I could make dollar signs count as an 'environment'?

If there's not a built-in or ready-made way, don't worry about posting a solution. I'll try to figure it out myself. You can post one if you want though, in case I fail.

Thanks emacs-ers.


texts: how to properly capture `diff` output in buffer (without first opening a file)?

texts:
summary

If one captures diff output to a file name=*.diff and opens that file in a buffer, one gets nicely-formatted mode=Diff. How to get that directly, without first capturing to a file?

details

I use diff a lot, not only via ediff-buffers (which I love) but also for more obscure purposes, like diffing outputs of processes. I've also been using Emacs for several decades, but continue to learn new aspects and uses. So I was not so much surprised as curious to find that, when I did (from the dir/folder of a local git repo)

$ git diff master origin/master > /tmp/foo__local_vs_remote.diff

and opened the file in a buffer, it displayed in a nicely/usefully colorized (à la ediff) mode=Diff. I had just never before simultaneously

captured diff output to a file
named the file *.diff
opened the file in Emacs

But now I'm trying to capture diff output directly to a buffer and get output like that of the happy mode=Diff, and am failing.

seeking genericity

Note also that, since I use diff in lots of contexts, I'm looking for a solution to the general problem, and not, e.g., just to the git diff problem (which I suspect Magit etc have solved). Seeking genericity, I'll test 3 usecases: "normal" file-vs-file diff, git diff, and process-substitution diff.

platform

$ lsb_release -ds
LMDE 2 Betsy
$ cat /etc/debian_version
8.3
$ uname -rv
3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29)
$ emacs --version
GNU Emacs 24.4.1

options

shell-command

If I do the following (possibly after navigating to a buffer with an appropriate working directory)

M-! <diff command/>
C-x b *Shell Command Output* (where the output of M-!==M-x shell-command goes by default)
M-x diff-mode

... I get the nicely-formatted output. Furthermore

this works for all 3 testcases
if one runs M-! with another diff command, the new output just overwrites the old, but the buffer maintains diff-mode without user intervention
no keybinding changes (as with term-mode)

Chosen answer.

shell-mode

If I either

M-x shell, goto the correct dir/folder, and run git diff master origin/master
am in a buffer on the correct dir/folder, and run M-& git diff master origin/master

I get the dreaded WARNING: terminal is not fully functional.

term-mode

As Emacs User points out, M-x term performs better for this usecase than M-x shell: if I M-x term, goto the correct dir/folder, and run git diff master origin/master, I get nicely colorized output. It's not exactly mode=Diff, but it does the job. Unfortunately

That only works for git diff: I get no colorization for either process-substitution or file diff.
I find the term-mode keybinding changes highly annoying.
I also found term-mode navigation odd: when editing history, my cursor would sometimes bounce around oddly.
solved).


texts: Why does `assoc` return nil for a plist?

texts:
I've got the following issue:

(setq testvar '(link (:type "http" :path "//pygments.org/docs" :format
bracket :raw-link "http://pygments.org/docs" :application nil)))

(setq testvar (nth 1 testvar))
(assoc :path testvar) ;;nil --- why?

I can't get a value of any of this keys, what I'm doing wrong?


texts: How to compute ln in Org-Mode spreadsheet

texts:
Is there a formula to compute the natural logarithm of a number in Org-Mode spreadsheet? For example, to compute ln(1), Excel or Calc formula is =ln(1), what would it be in Org-Mode?
The result should be 0 as ln(1)=0.


texts:
Prettify seems to work well with languages like matlab or python by ignoring things like addition (+) or multiplication (*) when directly next to the symbol. I'd like to add things like underscore (_) to that ignore list, but I can't seem to find out where.

Python-mode seems to automatically do this, but it's not always active, so I imagine it must be stored in some kind of list. I imagine it has something to do with: How to prettify symbols inside comments?, but I can't seem to figure it out.

How do I go about doing this?


texts: Bold markup not working for Chinese text when exported to html or to pdf output from org-mode

texts:
Here is an example,

#+LATEX_CMD: xelatex
#+LATEX_HEADER: \usepackage{xltxtra}
#+LATEX_HEADER: \setmainfont{AR PL KaitiM GB}
This is a *test*

这是*测试*

The resulted HTML output is the following:

This is a test

这是*测试*

I also tried output to PDF, the problem is the same: no effect for the Chinese text.

I also tried the other markup, emphasise, underline, the problem is the same.

I wonder what is the solution for the problem?


texts: Mass conversion of text files in a folder to one .org file

texts:
Assume a structure like this:
2014
...
2015
 CustomerfolderA
  ConfigfileDeviceA_2015_01_01_0800.txt
  ConfigfileDeviceA_2015_01_02_0800.txt
  ...
  ConfigfileDeviceB_2015_01_01_0800.txt
  ...
  ConfigfileDeviceC_2015_01_01_0800.txt
  ...
  MiscCustomerInfos.txt
  Bla.txt
  BlaBla.txt
  ...
 CustomerfolderB
 ...
2016
...

What I want is to convert all the text-files of a folder to one org mode file per folder. The org headings should contain the name of the orginating text files and below should be the content of the orginating text files. What would be the exact commands to reach that goal?

Find in combination with Pandoc should be a solution. I found the releated thread about markdown-file conversion below, but the altering is too difficult for me.

How to migrate Markdown files to Emacs org mode format


texts:
Anyone know of a way to convert rmarkdown (rmd) files to orgmode?

im preparing a R course and lots of cool examples in R are in rmd format so it could be very useful to me.
I tried via pandoc but results were not great


texts: install missing external packages automatically from within emacs

texts:
I have some snippets in my config, that depend on external tools. For example I use xmodmap at startup.

(if (eq window-system 'x)
    (if (file-exists-p "/usr/bin/xmodmap")
        (shell-command "xmodmap -e 'clear Lock' -e 'keycode 66 = F13'")))

Is it possible to install xmodmap automatically if it isn't installed ?

EDIT

@Ehvince When I install xmodmap in the else clause, the xmodmap command won't be executed. I think I need some piece of code that waits for the subprocess to be finished before executing the xmodmap command ?
Another problem is, I can't install a package when I start emacs without sudo. So I need a password prompt, I guess.


texts: How do I automatically clock-in for SCHEDULED items with org-capture?

texts:
I would like to setup my org-capture template for meetings so that I get automatically clocked into the meeting header on the day and time of the meeting.  So given:

* Meeting with client
  SCHEDULED: <2020-05-01 Fri 09:00-09:30>

I would like to be clocked into that issue on Friday morning at 9am.


texts: Why needs syntax highlighting often a `revert-buffer`?

texts:
Quite frequently, syntax highlighting in a given buffer is broken (i.e., a big fraction of the code is not highlighted).  This is definitely not due to syntax errors, and the point at which highlighting stops quite often is in the middle of an identifier.  Then, a revert-buffer regularly restores the highlighting.  Of course, it is annoying to be forced to do so over and over again.  What is the root cause of this, and how can one make the syntax highlighting more robust?

I observe this on python-mode buffers since I program almost exclusively in that language, but I have observed this in other modes, too.


texts: Which `ls` program is used when running dired over tramp?

texts: How does dired determine which ls program to use when running over tramp? I couldn't find it anywhere in the document. If it is insert-directory-program, what would it do if the path doesn't exist on the remote host?


texts: Selecting next occurrence of word incrementally

texts:
I want to make changes inside a paragraph of a large text file.

If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.

I'm looking to replace "foo" with "bar" in a paragraph.

This is similar to Sublime Text's Ctrl-D


texts: How to print colorful and bold string in the mini-buffer

texts:
When I do echo "\033[1;31mThis is bold red text\033[0m" it should print This is bold red text as red and bold. When I try it in the emacs's shell it prints it as it is instead showing the ansi-color.
example:
M-x shell-command and echo "\033[1;31mThis is bold red text\033[0m" enter.
=> How could I fix this?
my setup:
(require 'ansi-color)
(defun colorize-compilation-buffer ()
  (toggle-read-only)
  (ansi-color-apply-on-region (point-min) (point-max))
  (toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) ;;

Please note that: output is printed in the minibuffer, I am not sure can color could be shown in the minibuffer.


texts:
Is it possible to highlight matching quotes as show-paren-mode does with parentheses? The characters I'm looking to highlight are "dumb" quotes, both single (Unicode: apostrophe, U+0027) and double (Unicode: quotation mark, U+0022).

Sometimes I get lost in Fortran format specifiers, like '("strg1", i2, "strg2", i11)'. Highlighting matching quotes there would help me tell apart the pieces of the specifier.

I'd prefer not to use smartparens. If your solution uses it please provide a set-up that just highlights matching quotes without otherwise altering the pairing or highlighting of matching delimiters.


texts:
I have a directory ~/mail containing directories and Maildirs.

I was hoping I might read messages contained in it by evaluating

(setq gnus-select-method '(nnnil "")
      gnus-secondary-select-methods
      '((nnmaildir "private" (directory "~/mail"))))

and M-x gnus.  But I see only an empty buffer.  How do I find my messages?


texts:
My config is full of advice, and I keep hearing about the new shiny minimalist nadvice.el package.

I've searched the manuals, and I've read the source, but I'll openly admit: I still have no idea how to actually use it.

Can anyone here point me to a guide, or tell me how to get started porting my old-style advice over?


texts: How do I stop emacs open certain files in conf-mode?

texts:
By default, my Emacs opens config.php in conf-mode. It looks like conf-mode uses a set of regular expressions to match the filename, but I can't figure out how to make it open in php-mode.

Any idea?


texts:
I write (and rewrite) a lot of mathematical formulas in LaTeX with Emacs. I frequently run into situations where I want to change a pair of matching parentheses, to improve readability. My Emacs is kind enough to show me the matching delimiter, but how do I change it programmatically?

For example, change the outer delimiters in one go:

( (\sqrt{a} + b)^{-1} + c^{-1} )

to

[ (\sqrt{a} + b)^{-1} + c^{-1} ]


texts: How to have the sum of a column (with computed data) in the first row?

texts:
In org-mode is it possible to generate a table, where there is a column which contains a value computed from values in the other columns and which contains the sum of these values?

More specifically, at the moment I have a table with seven columns, where the last two columns contain values computed from values in the other columns using the following formula:

#+TBLFM: $6=$4-$3;t::$7=$4-$3-$2;t

I would like to include the sum of the last column.  Is this possible? If yes, how can this be achieved? When I tried to do this I always got zero. Ideally I would like to have the sum somewhere outside of the table or in the last row (even if I add new rows).


texts:
A code base I work on has the macro

#define when break; case

to make switch statements 'cleaner'

However this causes problems with indentation,

Is it possible to set the behavior of 'when' to be the same as 'case'?


texts: How do I disable the emacs flyspell middle mouse correction?

texts:
I already use middle mouse to paste/yank. However flyspell seems to hijack this, making it impossible to paste in the vicinity of a correctable word.

With the help of this question I have discovered that I can add the correct-word functionality to the more sane right-mouse button with

(eval-after-load "flyspell"
  '(progn
     (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
     (define-key flyspell-mouse-map [mouse-3] #'undefined)))

however this doesn't change the middle mouse button behaviour.

How do I clear flyspell's default binding of the middle mouse so I can always use middle mouse to paste? It would also be appreciated if the relevant lisp could be explained. Although I managed to copy and paste the above to good effect, it's inner workings are a mystery to me.


texts:
I don't know whether this is possible or not.
I know I can edit remote files, but what I am looking for is a setup like this:

one buffer with dired on my local directory
one buffer with dired on the remote directory

Sort of a visual aid when updating my files on the remote directory. Marking multiple files and updating them via FTP would be quick if it was possible from this kind of configuration.


texts:
What is the correct way to bind keys only for X frames? E.g. some key combinations are part of terminal escape sequences, but otherwise should be bindable when not running in a terminal.

Currently, I use an after-make-frame-functions hook:

(defun my-setup-nontty-bindings (frame)
  "Set up TTY-incompatible keybinds for FRAME, if it's not a TTY."
    (unless overriding-terminal-local-map
      (setq overriding-terminal-local-map (make-sparse-keymap)))
    (define-key overriding-terminal-local-map (kbd "M-[") 'cs/forward-or-backward-sexp)
    (define-key overriding-terminal-local-map (kbd "M-]") 'er/expand-region)))
(add-hook 'after-make-frame-functions 'my-setup-nontty-bindings)

This almost works, however:

A frame is not exactly the same as a terminal, and overriding-terminal-local-map is a per-terminal, not per-frame variable;
A non-nil overriding-terminal-local-map breaks international input, which is apparently by design.


texts: How to make tooltip background transparent?

texts:
I want to make the tooltip background somewhat transparent, say, change it alpha value to 0.5.

I find these code in tooltip.el.gz

(defface tooltip
  '((((class color))
     :background "lightyellow"
     :foreground "black"
     :inherit variable-pitch)
    (t
     :inherit variable-pitch))
  "Face for tooltips."
  :group 'tooltip
  :group 'basic-faces)

There is a :background property, so my question is:

How to change this value in my init.el so that I do not change the origin file.
How to make it transparent?

Thanks!


texts: All arrow keys in dired+ buffer mapped to M-O

texts:
For some reason when I press Up, Down, Left or Right keys on keyboard in dired+ mode, emacs reads them all as M-O key, which I found out by describe-key command in dired+ buffer. I have no config regarding diredp in my config, just that:

(use-package dired+
  :ensure t)

Also, when pressing arrow keys in diredp in minibuffer appears change owner of auto-save-list, and depending on Up, Down, Left, Right, character appear in input field are A, B, D, C, which is even more confusing.

In ordinary dired buffer arrow keys appears normally. Also I'm working in emacs-nox session.


texts: make emacsclient connect to running emacs

texts:
In my .emacs I have (server-start).
In my .bashrc I have:
export ALTERNATE_EDITOR="emacs-snapshot"
export VISUAL="emacsclient-snapshot -c"

When I run emacsclient -c EXISTING-FILE on the command line, I start a new Emacs, rather than connecting to the existing one.  What am I doing wrong, and how can I change it so that emacsclient finds the existing Emacs?

To confirm that there really are two processes: in a shell within the original Emacs:
$ ps -A | grep emacs
24646 tty2     00:00:03 emacs-snapshot
24658 ?        00:00:00 emacsql-sqlite

In the new one launched by emacsclient:
$ ps -A | grep emacs
24646 tty2     00:00:03 emacs-snapshot
24658 ?        00:00:00 emacsql-sqlite
24839 pts/0    00:00:03 emacs-snapshot
24897 ?        00:00:00 emacsql-sqlite

Is this pts/0 a clue?


texts: Emacs flickering when using before-save-hook with gofmt

texts:
I am trying to use gofmt on my go before I save it.

; Run gofmt before save
(setq gofmt-command "goimports")
(setq exec-path (cons "/usr/lib/go/bin" exec-path))
(add-to-list 'exec-path "/home/giodamelio/Projects/go/bin")
(add-hook 'before-save-hook 'gofmt-before-save)

The problem is, whenever I try to move the cursor(either with C-n/C-p, or with evil), the contents of the buffer seem to flicker. It is not the entire buffer(not visual bell), and it is not the same bits of text each time.

When I comment out those four lines it goes away, so I know it has somthing to do with them, but my understanding of the before-save-hook is that is will only run before I save, not whenever I move the cursor"


texts: how to automatically clean indented blank lines?

texts: In python mode when I'm done with an inner indented block I hit return, then backspace to return to the previous indentation and then another return so that there's a blank line before I start the code following that indented block.  This leaves a blank line that has only tabs or spaces.  I try and find them and remove the tabs and spaces with M-\ but it would be more convenient if there was a save file hook that would find all of them and do this cleanup.  Is there something that does that?


texts: Emacs and IPython integration: multiple lines sent

texts:
I am using emacs with Anaconda's IPython console:

(setq python-shell-interpreter (substitute-in-file-name "$HOME/anaconda3/bin/ipython"))

IPython opens after C-c C-p, but always with four empty input lines at the beginning:

Also, when I send a command by selecting a region and C-c C-r (print('words')) in this case, again four empty lines show up and then the result:

How to fix this? I don't have any IPython related configuration apart from the line that I pasted at the top.


texts: Changing the completion speed in company

texts: Is it possible to change the speed in which the company shows suggestions for completion? Per default it takes too long, so that it is still faster if one types the word himself than waiting for company suggestions.


texts: How do I get all marked files from all Dired buffers?

texts: I'm trying to write a function that opens all marked files externally in their default programs. I've tried using (dired-get-marked-files) to get the filepaths, but that only returns the marked files in the current buffer. Is it possible to get all marked files from all dired buffers?


texts: Instructions on how to work with Evil Mode

texts:
I am considering in giving Evil Mode a chance. I have searched extensively to find how do you use it and everyone is just sharing their customizations.

What I can't understand is when you install and activate Evil Mode does automatically use the keys of Vim or you have to customize them to your needs? To put it another way when I activate it should I change anything or everything will work?

One more thing. In Emacs when you install packages you should use specific keys for some tasks. For example in AUCTeX you use C-c C-c to compile so   in Evil Mode what keys do you use for the packages? You have to customize them for every package?


texts: Spaces get trimmed when I use org table in (R) code block

texts:
Please, help! I use literate programming and I want to use org-mode tables as data for my R code blocks. However, when it comes to cell values that have meaningful leading and trading spaces org-mode either removes it or escapes the quotes. I would very like to leave such spaces in place when I quote the value in the org table cell.

Example:

#+name: test-table
| name      | string                                                            |
|-----------+-------------------------------------------------------------------|
| example-1 | "  a string with very important leading and trailing spaces "     |
| example-2 | ""  a string with very important leading and trailing spaces ""   |
| example-3 | """  a string with very important leading and trailing spaces """ |
| example-4 | \"  a string with very important leading and trailing spaces \"   |
| example-5 | '  a string with very important leading and trailing spaces '     |
| example-6 | \'  a string with very important leading and trailing spaces \'   |

#+header: :var data = test-table
#+begin_src R  :tangle no :results verbatim
  ## get value column and quote it to see if spaces are in place
  paste0("\"", data[[2]], "\"")
#+end_src

It gives me the following results:

#+RESULTS:
: "a string with very important leading and trading spaces"
: ""
: ""
: "\"  a string with very important leading and trading spaces \""
: "'  a string with very important leading and trading spaces '"
: "\'  a string with very important leading and trading spaces \'"

What I would like to have is just a string as it was in the table. Like this:

: "  a string with very important leading and trading spaces "

I looked where it gets trimmed and I think it is somewhere in orgtbl-to-generic function, but it converts the table (in lisp format) back to org table and uses custom export backend to print it to tsv. I could not figure out where it removes the spaces and how to fix it. It might be a bug. I think that normal behavior should be the one that I was expected initially.

Can you, please, help me with getting around it?


texts: If an emacsclient has an open minibuffer when it's closed, it freezes everything

texts:
I use emacs --daemon for everything, which means I frequently have several different instances of emacsclient running at a time. I've noticed that if I execute an action which opens a minibuffer, it freezes all of the other clients, as detailed in this question. This is annoying but it's not so bad if I can find the instance of emacsclient which has the open minibuffer and close the buffer.
But if I inadvertently close the terminal running emacsclient, while that client had a minibuffer open, then I can't close the minibuffer, and the end result is that every client is frozen and I have to completely shut down my emacs server, which is an enormous pain, due to having to reopen a ton of files and long-running ansi-term sessions, not to mention potentially losing work.
I don't know of a workaround for this situation. kill -USR2 works for some cases of frozen emacs, but doesn't seem to work for this. I tried kill -HUP but that just ended up nuking the whole server, which is.... not good at all? Help!


texts: Error when loading new version of org mode

texts:
I upgraded Org-mode to the latest version on the master branch (according to How to install latest version of org mode?) and now I get this error every few seconds:

Error running timer ‘org-indent-initialize-agent’: (void-function org-time-
add) [8 times]

When I run org-version, I get 9.1.9, instead of the 9.3.3 from the master branch; yet I don't have this problem with just my local version.

What is the problem, and how can I fix it?


texts: How to auto-format the source code block in org-mode

texts:
When I'm using org-mode to take notes about a book, sometimes I'll copy/paste some code snippets into the note file. After pasting it, I'll

1. `C-c '` to call `org-edit-special`
2. `C-x h` to mark all the source code
3. `TAB` to format it

Is there a solution in org-mode for me that, after pasting code in #+BEGIN_SRC...#+END_SRC, it will automatically format the code block or I can use just one key such as TAB to format(indent) the whole source code block?

The default TAB(typed in block, not using C-c ') is just align all lines 2 columns after #+BEGIN_SRC header, if there are spaces at the beginning of the second line, it will just add more spaces, it will not indent all lines like the 3 steps.


texts: How to pass messages between emacs and a Python program? (goal: trying to use emacs as a UI)

texts:
The situation.

Say I have opened up a file in emacs, and I type in something like:

x \and \top

Then, a Python program reads that file, and:

replaces all \and to ∧
replaces all \top to T
it does some thinking on the expression x \and \top and decides that that is the same as x, so will append an = x

The final result of all the changes made by the program to the file will leave it like so:

x ∧ T = x

Question: how should I pass messages between emacs and a Python program?

I don't want the Python program to be constantly polling the file for changes (using a while loop), and I probably don't want emacs to be constantly polling the file for updates (which I know how to do using the auto-revert command).

Maybe I press some key combination, and then that sends a message to a Python script that its time to read the file and make updates and then the  Python script would message emacs and ask it to update what it is displaying in its buffer.

How could this be done?

My goal: I want to take advantage of the fact that emacs knows how to intelligently display pixels on a screen in an interactive way (it can manage dividing up the screen space, display text and allow editing, syntax highlighting, etc.). I want to take advantage of my knowledge of Python to do heavy programming (rather than using emacs Lisp), and emacs would be the UI for this program. I view communication between emacs, and the Python program as crucial to achieving this goal. If there is a better way to think about this though, I'd love to learn (for instance, maybe I really should be involving emacs Lisp a lot more, and eliminating Python entirely?).


texts:
I am learning Dired in Evil mode.
h j k l / are Evil keys that obviously work in Dired.
Are there others?

Is there a table of Evil keys for Dired?

I am using Emacs 25.2.1 with Evil, Spacemacs, and Ivy.


texts: How to export org files to plain text files as it looks like in clean view?

texts:
I want to print org files or share them with in emails.  Clean view looks good for these purposes.

Is it possible to export org files so that the output text file looks exactly like clean view (of course without theme colors)?


texts: How to execute sudo command in org-babel in relative path under current working directory

texts:
I want to execute sudo command in org-babel like this:

#+begin_src shell :dir "/sudo::" :cache no
make
sudo make install
#+end_src

It works fine. It use TRAMP /sudo: method.

But I need to execute sudo command relative under current working directory. As following
block shows:

#+begin_src shell :dir "/sudo::data/code/quirc" :cache no
make
sudo make install
#+end_src

But it does not work. It is under /root instead of current working directory.
So how can I execute sudo command under a specific directory as in org-babel
like upper?

EDIT:
Might add an advice to change TRAMP sudo method default directory to babel src block's directory? Don't know how to change this in TRAMP code. Have not found any tramp-default-directory related variables.


texts:
When trying to define a macro in emacs and trying to expand key-chord in process its not working - its simply inputs letters instead. I saw explanation of this in key-chord.el but is there any workaround for this? Thx.

Here's explanation from key-chord.el:

;; When recording keyboard macros, the time between keyboard inputs are not
;; recorded. Thus, the key-chord-input-method cannot know for sure if two keys
;; in a macro was a chord or not. The current solution remembers the first key
;; of the chords typed during macro recording, and keys that match those (and
;; are defined as chords) are considered key-chords during macro execution.
;; This knowledge is not saved with `name-last-kbd-macro', so they may
;; execute wrong if they contain pair of keys that match defined chords.


texts: customize creates custom-set-faces unintentionally

texts:
I just edited the variable org-M-RET-may-split-line with easy costumize, saved and applied. I checked my dotfile right afterwards and noticed that

(custom-set-faces
'(default ((t (:foreground "#DCDCCC" :background "#3F3F3F")))))

was added to my dotfile. This already happened a few times to me when using easy customize. Any idea how to prevent this?

EDIT: I'm able to reproduce the issue:

start spacemacs with emacs
open dotfile with SPC f e d
SPC f1 python-shell-interpreter
change value to python3
apply and save
bottom of dotfile, this is what was added:

;; Do not write anything past this comment. This is where Emacs will
;; auto-generate custom variable definitions.
(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.
 '(fci-rule-color "#383838" t)
 '(nrepl-message-colors
   (quote
    ("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3")))
 '(org-M-RET-may-split-line (quote ((default))))
 '(pdf-view-midnight-colors (quote ("#DCDCCC" . "#383838")))
 '(python-shell-interpreter "python3")
 '(vc-annotate-background "#2B2B2B")
 '(vc-annotate-color-map
   (quote
    ((20 . "#BC8383")
     (40 . "#CC9393")
     (60 . "#DFAF8F")
     (80 . "#D0BF8F")
     (100 . "#E0CF9F")
     (120 . "#F0DFAF")
     (140 . "#5F7F5F")
     (160 . "#7F9F7F")
     (180 . "#8FB28F")
     (200 . "#9FC59F")
     (220 . "#AFD8AF")
     (240 . "#BFEBBF")
     (260 . "#93E0E3")
     (280 . "#6CA0A3")
     (300 . "#7CB8BB")
     (320 . "#8CD0D3")
     (340 . "#94BFF3")
     (360 . "#DC8CC3"))))
 '(vc-annotate-very-old-color "#DC8CC3"))
(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.
 '(default ((t (:family "Office Code Pro" :foundry "NATH" :slant normal :weight normal :height 120 :width normal)))))


texts: How to make the org-mode exported table aligned in GMail?

texts:
I have a table maintained by org-mode, and I would like to copy/paste it to an email.

So this is what I was trying to do:

export to the plain text
copy/paste to the gmail

However, it just cannot aligned correctly among different columns.. This is something like this:

Could anyone help me on this issue? Thank you!


texts: Check whether a line is in the middle of a block comment?

texts:
When, while executing an emacs-lisp function, point is at the beginning of a line, how can I check whether that line is part of a block comment, inside it, or starting it?

The stupid approach, that I am doing now, is to go to the first non-whitespace character and see if its face is font-lock-comment-face or some such:

(save-excursion
  (skip-syntax-forward "\\s-")
  (let ((face (get-char-property (point) 'face)))
    (or (eq face 'font-lock-comment-face)
        (eq face 'font-lock-comment-delimiter-face)
        (eq face 'font-lock-doc-face))))

But this fails sometimes, because the function that invokes this might be run before fontification is performed.

Is there some standard way of doing this? (Please include, if you can, a link to the emacs lisp manual section that I've missed.)


texts: Mapping new command involving  clear all predefined  commands

texts:
I have the command fill-paragraph mapped to key <escape> q, it is mapped by default in emacs.

Now I want to map the opposite command, unfill-paragraph, to key <escape> p.

However, when I do this all predefined commands with <escape> stops working. I need to explicitly remap all of them.

I am mapping the command like this:

(global-set-key (kbd "<escape> p" ) 'unfill-paragraph)

Is this the expected behavior? How can I map new commands to escape keys without clearing all predefined?


texts: I forgot to type :results none in babel and now I have a huge table in my org file. How can I select all of those lines and delete them? When I try the straight forward approach of moving to the end of the buffer, Emacs freezes up and I get a "Timed out waiting for property viewers" message in the minibuffer.


texts: org mode with clojure - can't get export to work

texts:
I'm a relative emacs newbie and have set up my emacs (24.4.1) to work with clojure.

The gist of it is that I am now using the latest org-mode from git and loading it in my init.el (I am using prelude btw) as below:

   (add-to-list 'load-path "~/repos/org-mode/lisp")
   (require 'org)
   (require 'ob-clojure)

I am trying to use org to write a literate clojure program that I can export to markdown. Clojure and babel now work well, evaluation works etc, but when I try to export my org file I get an error.

    load-with-code-conversion: Symbol's value as variable is void: p

The stack trace when I set toggle-debug-on-error is:

    Debugger entered--Lisp error: (void-variable p)
        eval-buffer(#<buffer  *load*> nil
             "/Users/krisfoster/repos/org-mode/lisp/ox.el" nil t)
             ; Reading at buffer position 229233
        load-with-code-conversion("/Users/krisfoster/repos/org-mode/lisp/ox.el"
             "/Users/krisfoster/repos/org-mode/lisp/ox.el" nil t)
        autoload-do-load((autoload "ox" "Export dispatcher for Org mode.\n
            \nIt provides an access to common export related tasks in a
            buffer.\nIts interface comes in two flavors: standard and
            expert.\n\nWhile both share the same set of bindings, only the
            former\ndisplays the valid keys associations in a dedicated
            buffer.\nScrolling (resp. line-wise motion) in this buffer is done
            with\nSPC and DEL (resp. C-n and C-p) keys.\n\nSet variable `org-
            export-dispatch-use-expert-ui' to switch to one\nflavor or the
            other.\n\nWhen ARG is \\[universal-argument], repeat the last
            export action, with the same set\nof options used back then, on
            the current buffer.\n\nWhen ARG is \\[universal-argument] \\
            [universal-argument], display the asynchronous export
            stack.\n\n(fn &optional ARG)" t nil) org-export-dispatch)
        command-execute(org-export-dispatch)

I tried to resolve this by (require-ing the various org export packages, the ones in the clone of the org git repo that is, from within my init.el. But no dice - in fact that generated yet more issues. I have tried debugging but can't figure out what is wrong. I am suspecting I need to be requiring something but don't know what.

I have my init.el here - init.el gist

Any-one have any ideas what I am doing wrong?

Thanks in advance.

EDIT

Just did an update of org-mode and built with make autoloads and now get a new error which is saved in this gist https://gist.github.com/krisfoster/247358228d2f2bd3089f.

Note I have had to remove the link to the original article whose setup I was following as I don't have enough rep. points to post more than 2 links.


texts: Replace element in a list / add in case of absence, with custom test/key functions

texts:
add-to-list doesn't refresh item, it only checks for existence of item by equal or custom comparison function:
(add-to-list
 'tramp-methods
 '("gssh" (tramp-login-program "gcloud compute ssh"))
 nil (lambda (a b) (equal (car a) (car b))))

What way can I replace definition in a list, that handles presence/absence of item and support custom comparison function?
tramp-methods is an association list. Is there something to set key/value with replacing existing entry?
UPDATE I found cl-pushnew & cl-adjoin but they don't replace, only adds if not there...
UPDATE 2 Found exactly same question: https://stackoverflow.com/questions/10063195/replace-item-in-association-list-in-elisp
There is no build-in library function that handles replacement of existing items with custom key/test function & that handles missing item case...
The close solution:
(setq tramp-methods (cons
                     '("gssh" (tramp-login-program "compute ssh 2"))
                     (cl-remove "gssh" tramp-methods :key 'car :test 'equal)))

I wonder if there is some cl- equivalent...
UPDATE 3 cl-union is the most closed so far, but it has undefined behavior when elements are equal...


texts: How can I have a progress bar so I can drag to specific point of a song in emms? With a progress bar, it gives a more straight sense on how much the music has been played.


texts: How can I navigate up/down a log from magit-rev-mode?

texts:
When I'm reviewing a patch series in magit I want to be able to look in detail at each patch in a tree. However there doesn't seem to be an easy way to navigate to the next/previous commit from inside magit-revision-mode. I end up having to switch back to log mode to select the next commit which is inefficient.

Does magit-revision-mode have any context for where in the log view it was when it was called?


texts: Browse line range of file in GitHub with Magit

texts:
Is it possible to select a range of code and open it in GitHub using Magit? I use the browse-at-remote package for this, but I wonder if this could be done from Magit. I'd like to navigate both from code selection and from a commit diff. Also, I'd like to be able to browse the master branch, even if I'm in a feature branch. Right now with browse-at-remote I have to manually replace the branch name with master in the GitHub URL.

Thanks!


texts:
In Calc Embedded Mode, you can define a variable with the := operator. You can then use it in an equation using the => operator and it will be automatically updated when you change the variable. See (calc) Assignments in Embedded Mode.

Example:

Create a new buffer containing:

x := 3

x + 2 => 9999

Invoke calc-embedded-activate (C-x * a)
Invoke calc-embedded-update-formula (C-x * u) on the bottom equation. It changes to x + 2 => 5
Now enter embedded mode on the top equation and change it to x := 30. The bottom one will change to x + 2 => 32.

But this doesn't work with functions. Create a buffer containing

f(x) := 2 x

f(2) => 9999

Invoke C-x * a anywhere and invoke C-x * u on the bottom equation. It changes to f(2) => f(2). Changing the top equation doesn't affect the bottom one.

Is there any way to define a function from within Calc or does it have another way of dealing with this? I know of defmath but that doesn't help in e.g. a Latex document (unless you define the function twice, likely making mistakes).


texts:
I have the following wrapped text, especially when you use a lot of windows:

I'm wondering if the indentation of wrapped text could be changed like in Vim:

When figuring out, it seems the AutoFillMode is responsible for this. I was hoping this might be improved in Emacs 25. After upgraded to a compiled binary of Emacs 25, I see the same behaviour.
So I'm wondering if I could solve this in an another way?


texts:
I send emails with C-x m and AFAIK everything is configured
OK. However, recently I got this response when I wanted to send an email:

  smtpmail-send-it: Sending failed: 535 5.7.8 Error: authentication failed:
  Connection lost to authentication server in response to AUTH PLAIN <long
  hash here>

My second attempt resulted in (from *Messages*):

  Sending via mail...
  Sending email
  Sending email done
  Sending...done

Now I have two questions:

Why did it fail the first time?
Can I be sure that my email has been sent after all?

Update: through experiments I've discovered the following:

This happens when title of email is written using Cyrillic script;
Email is delivered anyway on second attempt.

Seems it's sort of bug, but I will wait for additional clarification.


texts:
I would like to be able to use CTRL and SUPER key modifiers together in a keybinding. Since I'm on Mac OSX  I use Command key for SUPER modifier.

I tried this:

(global-set-key (kbd "C-s-i") 'move-line-up)
(global-set-key (kbd "C-s-k") 'move-line-down)

but I get <C-s-268632073> is undefined message in the mini buffer when I press C-s-i combination.

Is there a way to use CTRL and SUPER key modifiers together in a keybinding?


texts:
I have tried using CUA mode but that failed to set this keybinding. I have also tried adding:

(global-set-key (kbd "C-x") 'kill-region)

to my ~/.emacs file. Despite this presently the Apropos buffer (started by pressing Ctrl+h+a) says the following:

kill-region           <menu-bar> <edit> <cut>, <S-delete>, C-w..C-x
   Cannot open doc string file "DOC"

about the kill-region command. Any ideas how to get Ctrl-x as the keybinding for cut. Here is my ~/.emacs file.


texts: Preserving evil mode search/replace command history

texts:
In evil mode, I use a lot of search/replace with %s/pattern/replacement. I have
(evil-select-search-module 'evil-search-module 'evil-search)
in my ~/.emacs file. However, some of the past search/replace commands seem to disappear from the command history as I scroll it with by entering :%s <UP-ARROW> in the mini-buffer.
Is there a way to troubleshoot this further and fix it? For e.g I have run at least 30+ unique search/replace commands in the past few months but the command history only displays a few. I can view all the commands : <UP-ARROW> but not all those which involved a search/replace operation.


texts: Gnus: mark all articles older than X-month as read

texts:
When I visit usenet or gmane group for the first time I want to see only recent articles.

Is it possible to mark articles as read based on their publication date?


texts: How to programmatically export org buffer to html ( mimic the org mode sequence `C-c C-e h o` )?

texts:
In brief:

I would like to programmatically mimic the org mode sequence C-c C-e h o to export a buffer to HTML and open the web browser.

My scenario:

I have a written a shell-command (in my code snippet below, this command is remplaced by the simple "more" command) that processes the current buffer file (the (buffer-file-name) part).
the shell command (here "more") generates an org mode compatible output and stores it in new_buffer.
my problem: I want to export this new_buffer into an html file and open the browser (like the manual C-c C-e h o sequence).
then I kill the temporary new_buffer

-> I do not know how to do that. For the moment I use org-html-export-as-html, however this function simply exports the created new_buffer into a new *Org HTML Export* buffer.

What I have done so far (with my brittle emacs-lisp knowledge):

 (defun generate_html()
  (interactive)
  (let ((new_buffer (generate-new-buffer (concat (buffer-file-name) ".org"))))
    (shell-command (concat "more " (buffer-file-name)) new_buffer)
    (org-html-export-as-html ) ;; <-- what to do here to mimic C-c C-e h o ?
    (kill-buffer new_buffer)))


texts: How to get org-mode to generate code multiple times in one file without redundancy?

texts:
(Follow-up to Is there a way to use org-mode to render generated code?)

#+BEGIN_SRC sh :exports results :results output :wrap SRC haskell
sed '/^elts/,$p' -n Heap03.hs
#+END_SRC

lets me extract Haskell code from a file to show in org-mode's export. It's effectively a safer and more idiomatic version of the hack I came up with:

#+BEGIN_SRC sh :exports results :results output verbatim raw
echo '#+BEGIN_SRC haskell'
sed '/^elts/,$p' -n Heap03.hs
echo '#+END_SRC'
#+END_SRC

Now I want more abstraction. For example:

#+NAME: inline
#+BEGIN_SRC sh :exports none :results output verbatim raw
echo '#+BEGIN_SRC haskell'
echo "[[./$FILE][$FILE]]"
sed '/^elts/,$p' -n $FILE
echo '#+END_SRC'
#+END_SRC

#+CALL: inline(FILE="Heap01.hs")
#+CALL: inline(FILE="Heap02.hs")

The two criteria I'm trying to satisfy (and having trouble) are:

I should have a link to the file automatically inserted above the Haskell code.
The call should be as minimal as possible.

I haven't figured out how to get the first criterion satisfied using :wrap, and the best I can do toward the second criterion is #+CALL: inline(FILE="Heap01.hs") :wrap SRC haskell, which is just a bit too heavyweight for my taste.

Thanks!


texts:
I generated multiple frames by C-x 5 ....
Is there a way to change the order of frame when we visit using C-x 5 o ?


texts: How to capture fields from bibtex by using org-ref

texts:
I want to use emacs org-mode to take notes of my bibliography. I am trying to capture some fields from a bibtex file and insert them into an org file with the org-ref-open-bibtex-notes. This is not working for me.

For example, I have a bibliography.bib:

@comment -*- org-ref-bibliography-notes: "./articles.org" -*-

@article{Mouhot2010,
  author = {Mouhot, C. and Villani, C.},
  title = {{Landau Damping}},
  journal = {J. Math. Phys.},
  number = {1},
  volume = {51},
  year = {2010},
  doi = {10.1063/1.3285283},
}

The first line sets the local variable org-ref-bibliography-notes to "./articles.org". If I run M-x org-ref-open-bibtex-notes, the file ./articles.org is populated with:

# -*- org-ref-default-bibliography: ("./articles.bib") -*-

** TODO -
 :PROPERTIES:
  :Custom_ID:
  :AUTHOR:
  :JOURNAL:
  :YEAR:
  :VOLUME:
  :PAGES:
  :DOI:
  :URL:
 :END:

cite:

The bibtex fields like author or year are empty. How can I capture these fields? Alternatively, I would like to get the following output:

# -*- org-ref-default-bibliography: ("./articles.bib") -*-

* Mouhot and Villani (2010): Landau Damping
  :PROPERTIES:
   :Custom_ID: cite:Mouhot2010
  :END:

I am using emacs 24.5.1, org 20190812 (orgmode elpa) and org-ref 20190802.1327 (melpa)


texts: Cannot edit ".gitignore" due to strange errors and read-only switched on

texts:
A new error has occurred with a recent upgrade to Emacs 27.1. I'm trying to edit .gitignore and get the following error:
*ERROR*: Unlocking file: Invalid argument, <directory>/.gitignore

To check this is not an error in an initialisation file, I tried with emacs -q .gitignore. However, in this case the file is set to read-only and cannot be edited, and the strange error
File exists, but cannot be read

appears, then the file appears but as read-only. It doesn't seem to be possible to change to non-read only. To surmount this problem I have taken to renaming .gitignore to another file name then moving that using the mv command. The file itself is not read-only:
$ ls -l .gitignore
-rw-r--r--  1 ben  ben  843 Sep  4 07:20 .gitignore


texts: get alist of org mode deadlines and times

texts:
Hi I would like to use the built-in notifications library in emacs with org mode (requires compiling with d-bus). I am trying to get it setup so that I can open my daily agenda view upon startup and have this trigger a series of (run-at-time .. calls that will run ~10 before the actual deadline. Problem is, I cannot seem to extract an alist of DEALINE . TIME entries of the deadlines in my agenda.
I have tried using the built-in org-agenda-get-deadlines but it  does not seem to work as
running (org-agenda-get-deadlines) results in a error.
I have tried "org-alert" and "alert" but they do not appear to work. Guessing some of their dependencies are depreciated or something.
How would I go about doing this?
UPDATE
HUGE thanks to @NickD for the help, here is what I have now in my setup. (Obviously could use some cleanup, but too excited atm).
(require 'appt)
(appt-activate 1)

(use-package notifications
  :demand t)

(setq appt-display-format 'window)

(setq appt-disp-window-function
      (lambda (nmins curtime msg)
        (notifications-notify :title "RING! RING! RING!"
                              :body (format "You have the appointment %s in %d minutes" msg (string-to-number nmins))
                              :app-name "Emacs: Org"
                              :sound-name "alarm-clock-elapsed")
        ))

(use-package org-agenda
  :init
  (setq org-agenda-finalize-hook 'org-agenda-to-appt)
  )

Obviously this requires opening your agenda at least once (and an emacs compiled with D-Bus support), but after that I get a nice

popup to appear starting within the appt-message-warning-time minutes of my scheduled deadline. Along with a reminder every appt-display-interval minutes within that time frame.
UPDATE 2
Just now noticing this, but you need to enter time in military time for it to work. AM/PM will show deadline in agenda but for some reason appt fails to pick it up. But this only applies if you edit the time manually. If you use the prompt then it looks like org fixes it to military time stamp.
PS
Wonder if there is a way to have the notifications to appear without initially opening the agenda if you work with an emacs compiled with systemd support? Donno whether the agenda can be opened in a daemon tho.


texts: How to revert a buffer without changing active modes?

texts:
M-x revert-buffer resets the active minor modes to the defaults for the underlying file. How can I preserve the minor modes active while reverting the buffer?

My attempt so far:

(defun revert ()
  (interactive)
  (let ((active-modes minor-mode-list))
   (revert-buffer t t)
   (setq minor-mode-list active-modes)))

This seemed broadly reasonable. Save minor-mode-list, revert the buffer, setq to restore. Calling (revert) seems to be exactly equivalent to calling revert-buffer and I'm not sure how to debug this.

What am I missing?


texts: make frames and open specific buffers in succession

texts:
im trying to launch emacs with specific named frames and want each frame to have a specific buffer opened in a specific frame (ie have the frame named FM opned a dired buffer at `~/~)

this is my current state of my conf to try to achieve this:

*** create startup frames
#+BEGIN_SRC emacs-lisp  :results none
(set-frame-name "MAIN")
(make-frame '((name . "FM")))
(make-frame '((name . "TERM")))
(make-frame '((name . "ORG")))

#+END_SRC
*** binds for frames
#+BEGIN_SRC emacs-lisp  :results none
(global-set-key (kbd "s-a") (lambda () (interactive) (select-frame-by-name "MAIN")))
(global-set-key (kbd "s-s") (lambda () (interactive) (select-frame-by-name "TERM")))
(global-set-key (kbd "s-d") (lambda () (interactive) (select-frame-by-name "ORG")))
(global-set-key (kbd "s-z") (lambda () (interactive) (select-frame-by-name "FM")))
#+END_SRC
*** open in frames
#+BEGIN_SRC emacs-lisp  :results none
(select-frame-by-name "FM") (dired-jump  "~/")
(select-frame-by-name "TERM") (eshell)
;; initial frame
(select-frame-by-name "MAIN") (find-file "~/org/files/agenda/TODO.org")

#+END_SRC

the frames are indeed generated and named correctly, yet i cany get the frames to open the correct buffer. im a bit at a loss.


texts: How to indent SQL code just 4 spaces, without alignment &c?

texts:
SQL mode has some cool stuff set up for indenting with aligned keywords and such. Normally, I'd think it was cool. The problem is that at my new job, the people who wrote our mountains of sql did not have this set up, and just indented sql 4 spaces.

I could bully them all into switching to emacs, but that's more of a long term project. In the short term, I want to make emacs indent sql in the stupid way lesser editors do it: 4 spaces, more or less ignorant of context. How would I do this?

EDIT:

A so-so solution is to create a mode hook with (setq indent-line-function 'tab-to-tab-stop). Unfortunately, this interacts badly with indent-tabs-mode nil and the lack of a customized backspace function. What i'd really like is something straightforward that would allow bounce-indent within a few levels.

EDIT2:

I no longer actually need this. I've just started indenting my own SQL correctly, and everyone else seems to appreciate it.


texts: How to make emacs or emacsclient exit with nonzero return code?

texts:
How to exit emacs with nonzero return code?

And how to achieve that also with emacsclient?

Duplicate of https://superuser.com/questions/295156/how-to-set-the-exit-status-for-emacsclient/542916


texts: Conditionally remove parts of a snippet when the corresponding input field is left empty?

texts:
When writing LaTeX code I use a snippet that expands begin to the following

\begin{$1}
    \label{$1:$2}
    $0
\end{$1}

This suits most of my purposes well, since I use labels rather systematically. Still there are often times when I do not need a label in an environment and I'd love for a slightly more sophisticated snippet to be possible. I suppose my question boils down to the following:

In the above snippet, is it possible to tell yasnippet to write

\begin{$1}
    $0
\end{$1}

if I have started typing part of the $0 input after leaving $2 blank?

I realize there are many reasonable alternatives to automating this, including using either a separate, non-labelled version of this snippet when I don't need labels or replacing the second snippet line with $2\label{$1:$3} and killing that line when unnecessary; this is more of an educational exercise for me about the more advanced features in yasnippets. I feel like knowing how to optionally remove portions of a snippet based on input would be useful in other applications. Thanks in advance for your advice!


texts: Can emacs open a series of files and split windows for each file in a template fashion?

texts:
I have a set of ~8 files in a sub-directory structure that is always the same.
/DirA/File1
/DirA/File2
/DirB/File3
/DirB/File4
...

and I find myself doing these steps to split windows and see/edit all the ~8files:
1 open one of the files in emacs
2 split windows into around 8 windows with C-x 2 and C-x 3
3 C-x-f to find/load each of the other files
4 change buffer to move the sequence of files from left/right, top/bottom

I was hoping someone might have an idea about how i could use emacs to say load a directory with these files/dirs and do all this splitting of windows and loading of files, assuming the files/sub-directories are always there. Perhaps one needs a certain file present to signify the parent directory eg emacs.template

see example image of tiled frame


texts: How can I sum (multiply ...) all elements on the calc stack?

texts: Sometimes I just want to sum a bunch of numbers in calc. Right now I press + until the stack is empty. Is there a shorthand for this?


texts: Show sum of efforts for a day in Org-Agenda day title

texts:
I would like to show sum of efforts for all tasks for a day in Org-Agenda day title. E.g. for a week agenda there would be 7 sums for each of the day, in their respective titles.

I think this could be done somehow by manipulating the org-agenda-format-date variable.

By default, this variable points to a builtin function org-agenda-format-date-aligned, but I suppose it can be reset to point to a custom function to include the sum of efforts in the date line.

Could you please help me define such a function?

Also, I would like to use a predefined Effort value for all tasks lacking the Effort property.


texts:
I have an org file with this content:
#+name: my-table
| *Type*  | *Value* |
|---------+---------|
| Web     |     744 |
| Checks  |     520 |
| Cash    |     105 |
|---------+---------|
| *Total* |    1369 |
#+TBLFM: @5$2=vsum(@I..@II)

I would like to add an R script to draw a bar chart of the result so I tried:
#+NAME: barchart
#+begin_src R :results output graphics file :colnames yes :session :exports none :var data=my-table[0:-2] :file my-table.png
library(tidyverse)
ggplot(data = data) + geom_bar(mapping = aes(x = X.Type., y = X.Value.), stat = "identity")
#+end_src

This results in:

I like the result except the "X.Value." and "X.Type." to label each axis.

Is what I'm doing the standard way to pass a table with column names
to R?
Is the R script written appropriately?
Is there a way to use my column names (i.e., "Type" and "Value") instead of "X.Value." and "X.Type."? Alternatively, can I change the axis label in R?


texts: How do I page when "ESC - (1 of n) [C-h paging/help]" shows in the emacs status bar?

texts:
I am an Emacs newbie having some problems navigating around when using the terminal, but pressing the ESC key brings up a huge list of key options which gives me the option of paging down and possibly select the right one, but any key I press seems to do the wrong thing.

I have 2 questions

How can I page down through the options?
For the option such as M-( I can effect them simply by pressing the  key after the dash eg (, but how can I effect those preceded with the C-, eg C-M-\? What does the C-M mean?

Because I am using Spacemacs I assume that Spacemacs cannot capture the SPC key as the terminal requires. Is the menu with this menu with C-M- and they M- the standard Emacs menu/keybinding?

PS. What is the proper name of the area the menu is displayed?


texts: Comment out / uncomment source blocks on state change in org-mode config file

texts:
I started to move my config file to an org-file just recently.

I wondered if it was possible to use the TODO state to activate or deactivate source blocks in the entry under the heading. This way it would be very easy to try out settings and customization.

Example: with #+TODO: ON | OFF

* ON use org-bullets
  #+BEGIN_SRC emacs-lisp
   (require 'org-bullets)
   (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  #+END_SRC

and after state change it would be

* OFF use org-bullets
  #+BEGIN_SRC emacs-lisp
   ;;(require 'org-bullets)
   ;;(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
  #+END_SRC

I thought about using the org-after-todo-state-change-hook but I know too litte elisp to go beyond that. The setting should only work in the config.org file, not in other org files.

Any helpful idea is appreciated.

P.S.: my M-x emacs-version is

GNU Emacs 26.1 (build 2, arm-unknown-linux-gnueabihf, GTK+ Version 3.24.5) of 2019-09-23, modified by Debian


texts: Evaluate single line of python code from Emacs org-babel

texts:
Consider a block of python code in an org-mode document:

#+begin_src python

num1 = input("Enter a number: ")
num2 = input("Enter another number: ")
result = float(num1) + float(num2)
print(result)

#+end_src

If I were to open a similar block of Rcode in org-edit-special I could use ess-eval-line to run this line-by-line or ess-eval-region to run a highlighted region.

How can I get similar functionality for blocks of code, written in python?


texts:
I was using regular find-file, where when I type D and press tab it will consider case sensitive file names, such as Driver.py and ignore others such as driver.

I have enabled: (ido-mode 1). I realize when I type D and press tab it also suggests driver and opens a complete suggestion window.

=> Is there any way to have ido to have same configuration as find-file, where case-sensitive is considered?


texts: bookmark-jump to a hidden part of a buffer

texts:
In elisp buffers, I use outline-mode in order to manage headings similarly as in org-mode. But when I jump to a bookmark which points to a hidden part of a buffer (because it is below a folded heading), the point ends up at the lowest visible heading which contains the bookmark position.

How can I unfold the corresponding part of the buffer and jump to the actual position of the buffer?

In org-mode however, the problem does not occur: we have the desired behavior.


texts:
I recently noticed an issue in man.el, in which sections in Man--sections are listed backwards. That is, the value is is something like:

(#("SEE ALSO" 0 8
   (face Man-overstrike))
 #("COPYRIGHT" 0 9
   (face Man-overstrike))
 #("REPORTING BUGS" 0 14
   (face Man-overstrike))
 #("AUTHOR" 0 6
   (face Man-overstrike))
 #("EXAMPLES" 0 8
   (face Man-overstrike))
 #("DESCRIPTION" 0 11
   (face Man-overstrike))
 #("SYNOPSIS" 0 8
   (face Man-overstrike))
 #("NAME" 0 4
   (face Man-overstrike)))

This is because Man-build-section-alist scans the buffer from (point-min) to (point-max), push-ing values onto Man--sections as it goes.

I wanted to change this behavior so that the sections are in the correct order, which matters to helm-mode.

However, changing the Man-build-section-alist function, then re-evaluating it doesn't do any good, because it's defined with defsubst instead of defun. defsubst inlines functions, which means that, when the file is byte-compiled, the function definition is directly inserted where the function is called. This means that redefining/evaluating the function doesn't work, since the bytecode is not changed.

defsubst offers a performance benefit, but is there really any reason to use it for a command like Man-build-section-alist? Most functions in man.el use defun, and I can't imagine that the performance benefit matters on hardware from the past 15 years.


texts: Use LaTeX accents with tex insert method

texts:
With this answer I learned how to insert math symbols with latex syntax directly into my buffer.
What I can't figure out is how to make accents insert properly. I want \hat{\beta} to insert beta hat ( β̂ ), preferably with circumflex directly on top.


texts: How do I get org-mode to treat the output of a non-latex code block as latex?

texts:
(Emacs: v27.1, Org: v9.5, pdfTeX: v3.14159265-2.6-1.40.21)
I am using the following Python code block to print LaTeX code:
#+BEGIN_SRC python :session :exports both :results output :wrap math
...
#+END_SRC

That prints:
M^{1} = \left[\begin{matrix}15000.0 \\ 15000.0\end{matrix}\right] \\
...

However, when I export to a LaTeX document, it is interpreted as:
M\textsuperscript{1} = [15000.0 $\backslash$\ 15000.0] \\
...

And that causes the LaTeX compilation to fail. How can I prevent Emacs from reinterpreting the output?


texts: Is it possible to bind `C-u C-x C-x`s behavior into `C-x C-x`

texts:
I have adviced to use C-u C-x C-x to jump back to latest position I jumped before. For example, if I do M-< and C-u C-x C-x, first I jump beginning of the file and come back to point I jumped.
When I do C-x C-x it does the same operation and also marks it. Since I don't need to mark it, is it possible to obtain C-u C-x C-xs behavior, when I press C-x C-x?


texts:
I am trying to use emacs with a background server running and client instances.
To do so, I lauch an emacs daemon with emacs --daemon. Then I open a client session with emacsclient -c. Doing like that and then visiting a file in the client session works fine. However, if I try to directly open a file with emacsclient -c file, there is a "Server" minor mode displayed in the mode line, and when I click on it and choose "Help for minor mode", a frame open with that text :

server-buffer-clients is an alias for `server-buffer-clients',
which is not defined.  Please make a bug report.

Then, if I close the client and open a new client, the file previously opened with emacsclient -c file isn't in the list of current buffers anymore (Ctrl-x b) while they stay in it if I just open a client with emacsclient -c and next visit them.

Why this behavior ? I am doing things wrong ? How to properly use emacs in client/server modes to have a persistent background instance with which I can interact ?

Thanks :-)

PS :
I am running emacs-24.5.1
I have also tried that without any customization (with no .emacs and no .emacs.d)


texts:
As you know, functions such as replace-regexp-in-string and replace-match have an argument LITERAL, meaning ...

If optional ... arg LITERAL is non-nil, insert NEWTEXT literally.
Otherwise treat ‘\’ as special ...

My intent is to replace all occurrences of a single-quote with a back-slash followed by a single-quote. However, the output does not evaluate that way:

 (replace-regexp-in-string "'" "\'" "a'b'c" nil t)

"a'b'c"

 (replace-regexp-in-string "'" "\\'" "a'b'c" nil t)

"a\\'b\\'c"

The result I need, by hook or by crook, is:

"a\'b\'c"


texts: Magit - How to drop all stashes at once?

texts:
I have created quite a few stashes and I wanted to drop all of them at once.

From terminal I could have done

git stash clear

I couldn't find a way to do it from magit.

I tried selecting all stashes and drop, but that didn't work.


texts:
I seem to have some misunderstanding with looking-at. This is my test
function :

(defun lkat ()
  "interactive looking at"
  (interactive)
  (if (looking-at "^\\s-*")
      (message "yes")
    (message "no")))

I would expect that it answers with "yes", if point is on any
whitespace after line-start. If I put my cursor at the first space of
a line, this works, but if I put it on the second space, it fails. Is
looking-at not greedy?

Thanks to anyone who points me to my mistake...