texts: How to highlight fragments of source and example blocks within an org-mode buffer itself

texts:
This is a variation on the theme of How to  code fragments in org-export.

Here the question is about making portions of src and example blocks stand out (preferably without breaking the syntax highlighting in the source blocks) in the org mode buffer itself, rather than during export.

Once again,

the highlighting should appear without the reader's intervention
fragments of lines should be highligtable.

Is there some not too painful way of doing this?

Edit to clarify:

The portions to be highlighted should be explicitly specified by the author, by some kind of markup (or perhaps by specifying the regions which should be highlighted in some annotation of the block), analogously to the way it was done in the linked question.

This markup could be the standard org =...=, /.../ and *...*, but I would be perfectly happy with other possibilities such as {{...}} or even ..., appearing within the src and example blocks, but being treated as markup rather than being rendered verbatim. Just like ... and {{{...}}} were used in the linked question and the accepted answer therein.

As for the appearance of the highlighting, I was thinking along the lines one of

a different face or overlay for the highlighted portions,
de-emphasize everything outside the highlighted portions à la fancy-narrow or ace-jump.

Background

I am looking for this in the context of trying to make presentations which discuss source code and the output it generates. I want to be able to attract attention to different portions of the source code and its output at different times (on different 'slides') according to what is being discussed at any particular moment.

It would also be important to keep the absolute position of the source code and any displayed output stable on the screen as the discussion (of that particular snippet) progresses. It would be fine (perhaps even desirable) for the positions to change once the discussion moves on to a different bit of code.

It would also be interesting to take advantage of the width of the screen, by positioning at least one of the three components

discussion
source code
output

further to the right, next to rather than below the others.


texts: Org-mode initial visibility: show each top heading's direct children only

texts:
I'm trying to achieve this visibility on startup:
* Top 1
** Sub 1.1...
** Sub 1.2
* Top 2
** Sub 2.1
** Sub 2.2...
** Sub 2.3
* Top 3
** Sub 3.1

That is, all top level headings should show their direct children. Not more and not less (I'd accept it if property/logbook drawers were visible, but optimally, I'd like them hidden). Is this possible using startup visibility (per-subtree) properties or anything else? It is achievable interactively by (starting form a folded view) selecting each top heading and pressing Cc TAB. I'm actually curious if this is something no one is missing in the default possibilities, or whether I've just not found it.


texts: Trouble with org-export-before-processing-hook in .emacs

texts: When I eval (add-hook 'org-export-before-processing-hook #'org-update-all-dblocks) in an emacs session, function org-update-all-dblocks seems to be called at the preprocessing stage of export, as expected. However, if i add the hook using the above line in .emacs and -- after restarting my GNU Emacs instance -- I call the LaTeX export function with C-c C-e l o from an org document, I get the error message "Wrong number of arguments: (0 . 0), 1" reported from the run-hook-with-args function. It is as if the org-export-before-processing-hook runs the hooked functions with an argument. Am I even supposed to adapt that variable? Also, how to achieve executing dynamic blocks on export, if what I attempted here is not the way?


texts: How can I set command-line parameters through `.emacs` file?

texts: Is it possible to set Emacs start-up command-line flags such as -nw and -q in an init file? If it is, how can I do that?


texts: How to rebind "special meaning" of C-u to a different key?

texts:
Excerpt from GNU Emacs manual:

C-u alone has the special meaning of “four times”:
it multiplies the argument for the next command by four.
C-u C-u multiplies it by sixteen.
Thus, C-u C-u C-f moves forward sixteen characters.

Is there a way to get this multiplication by sixteen when rebinding universal-argument to a different key? I did the following:

(global-set-key (kbd "C-i") 'universal-argument)

But when I press C-i C-i a only 4 copies of a are inserted, not 16 (if I rebind universal-argument back to C-u then I get 16 copies as advertised in the manual).


texts: libMagickWand-6.Q16.so.2 . . . No such file or directory

texts:
I just upgraded from Ubuntu 16.10 to 17.04, and now my Emacs (25.1.1), working fine before, is broken. Here is the error from running emacs --debug-init

emacs: error while loading shared libraries: libMagickWand-6.Q16.so.2: cannot open shared object file: No such file or directory

I've seen (older) answers that hit around this issue, but this problem came from a simple Ubuntu upgrade...


texts:
I deleted my old Python installation, so the only Python installation remaining  is the one inside Anaconda. when I start Spyder I get:
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.8.0 -- An enhanced Interactive Python.

Within a shell:
d:\docs\ML\scox>which ipython
which ipython
C:\anaconda3\Scripts\ipython.EXE

Inside my C:/emacs there is only python.el and no python-mode.el.
I made the following changes in python.el:
(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "-i")

(setq python-shell-virtualenv-root "C:/anaconda3/Scripts/")

Still, it does not start IPython (it does not start anything). Here is the output from the Messages buffer:
Source file ‘c:/emacs/emacs26/share/emacs/26.1/lisp/progmodes/python.el’ newer than byte-compiled file
apply: Searching for program: No such file or directory, python

What do I need to do to start the same process as the one, above, in Spyder?


texts: How to set block comment style in .dir-locals.el

texts:
When I do C-c C-k (c-toggle-comment-style) the value of comment-style remains indent. To achieve the same result as setting block comments, in my .dir-locals.el I have:

((c-mode . ((comment-start . "/* ")
            (comment-end . " */")
            (comment-padding . 0))))

but, emacs reports setting comment-start comment-end as unsafe. I was thinking it would accept changing the comment style as safe, but can't seem to find the right setting.


texts: how to tell a Custom Theme vs Color Theme?

texts:
I am considering changing the look of my emacs (just default state right now). I've read that Color Theme is an older approach but has its own advantages compared to Custom Theme (newer approach). One of the benefits of Color Theme seems to be the ability to completely turn it off and revert back to default state. Apparently, Custom Theme cannot be switched off in this manner.

Because Color Themes are undo-able, I want to install a few Color Themes to try out. But, when I start looking around, I see that a lot of Color Themes also have a Custom Theme version(?). How can I tell whether I'm installing a Color Theme vs a Custom Theme? Is there something in the .el file OR the way in which I have to alter my .emacs file that will tell me definitively?


texts: Recording a keyboard macro with actual character strings

texts:
I could not better word the question.

So, I have finalized a few M-x commands I want to execute on a buffer. I have also tried and tested a few regexps using C-M-% for search and replace.

Now, I want to put it all together. So, I C-x ( and run those M-x commands and do those substitutions by C-M-%. In both the cases, I select the command and search/replace strings using up and down arrows to choose the appropriate one.

When I name and save the macro, I find that it has recorded those up and down arrows after M-x and C-M-%! How do I get the actual commands and search/  replace strings?


texts: How to replace the default contents of the scratch buffer with the contents of a file (if it exists)?

texts:
I would like emacs to check for a ~/emacs.d/scratch.txt and use it's contents instead of the default message when emacs starts.

How can this be done?


texts: Babel org-mode, how to save the temporary file run

texts:
How can I save the temporary file that is used to run the script in a babel code block? I need to debug why the perl mode is not able to read values as tables any more.

Example:

#+BEGIN_SRC perl
print "hello world\n";
#+END_SRC

this outputs:

#+RESULTS:
#+begin_example
1
#+end_example

I would like to debug see what are the contents of the file sent to perl so I can debug its conversion to org.

Here is another example:

#+begin_src perl
my @array;
foreach $a (1..10) {
   print "$a\n";
   push @array, $a;
}
(1,2,3);
#+end_src

#+begin_example
3
#+end_example


texts: Creating a custom Yasnippet with conditions

texts:
I have a yasnippet that is conflicting with multiple-cursors because it is not exiting immediately.  When multiple-cursors is not active, I would like the snippet to pause and permit me to enter the data.  Can I have an example, please, of a yasnippet that uses some elisp conditions:

For example,

(if mc-mode
  \hspace*{$0}
  \hspace*{$1})


texts: Vertigo doesn't work properly with evil motions

texts:
I'm using vertigo with evil in the following way:

(evil-define-motion vertigo-j (count)
  "Evil vertigo motion. Count has no effect."
  (vertigo--jump #'evil-next-line "Jump down: "))

...and I map it to j with:

(define-key evil-normal-state-map (kbd "j") #'vertigo-j)
(define-key evil-visual-state-map (kbd "j") #'vertigo-j)
(define-key evil-motion-state-map (kbd "j") #'vertigo-j)

It works well enough for normal motion, but when I try to delete some lines (with dj), something strange happens. I go from:

1  It was on ▊a dreary
2  night of November that I
3  beheld the accomplishment
4  of my toils.  With an
5  anxiety that almost
6  amounted to agony, I
7  collected the instruments...

(where ▊ is point), and, by pressing dj and f (delete down 4 lines), I get:

1  It was on ▊at almost
2  amounted to agony, I
3  collected the instruments...

What should have happened is that the whole of the first line was deleted, along with the whole of line 5:

1  ▊amounted to agony, I
2  collected the instruments...

What is incorrect about my remapping, and how can I fix it to get the desired behaviour?


texts:
If I want to do recursive hardlinks of a directory I have to use cp -r -l dir in bash instead of ln -h. How do I replicate this in dired, because dired-do-hardlink uses ln underneath?

I can use M-! cp -r -l dir but I would like to not have to treat directories differently when linking files around.


texts: How can I link the source code .org file when exporting it?

texts:
I have an .org file in which I want to insert the source code that generated the web page when is exported to HTML, this is, the .org file itself, but when I do it's changed to the .html file. How can I achieve this?

This is the code of the link:

[[./documentation.org][Download .org source file]]


texts:
I currently use the following custom command to navigate between windows and frames:

(defun nispio/other-window (&optional arg)
  "With prefix argument, select the next frame. Otherwise, select the next window"
  (interactive "P")
  (if arg (other-frame 1) (other-window 1)))
(global-set-key (kbd "C-\\") 'nispio/other-window)

This allows me to jump between windows with C-\ and between frames with C-u C-\.  But what I would really like is a command that will let me cycle through all of the windows, regardless of the frame that the window is in.  Given the following window configuration:

             Frame 1                         Frame 2
   +---------------------------+       +------------------+
   +------------+--------------+       +------------------+
   |            |              |       |                  |
   |  Window 1  |   Window 2   |       |                  |
   |            |              |       |                  |
   |            |              |       |     Window 4     |
   |            |              |       |                  |
   +------------+--------------+       |                  |
   |         Window 3          |       |                  |
   |                           |       |                  |
   +---------------------------+       +------------------+

I want a command that freely cycles between window 1 - 2 - 3 - 4 - and back to 1 again.  I don't want to have to think about which frame a window belongs to in order to cycle through them.  Does such a command exist?


texts: rst mode indentation problems (electric indent off)

texts:
I've turned off electric indent. I am still having serious indentation problems with rst-mode -- making things nearly unusable.

First: I'd like to make all indentation two-spaces. No tabs, not ever.

Next: A weird and frustrating thing is happening with directives.

.. directive-with option:: option
                           The next line starts here

.. directive::
   :option: something
            The next line starts here.

.. directive::
   :why: would
         :anyone: want
                  :this: to happen?
                         :i-am: going insane.

ALL I REALLY WANT

I want to press  and have the next line indented by the same amount as the line I was just one. Then, if I want to indent, I can do so, and then stay at that level of indentation until I change it myself.
(I basically want this behavior in every mode, no matter what.)


texts: How to tell Tramp to load a remote .bashrc before executing commands remotely?

texts:
Problem: I have an elisp plugin which is failing on a call to start-file-process when executed within a remote directory. The issue is that the command I am trying to call with start-file-process doesn't exist until my /home/user/.bashrc (within the remote machine) is executed. Here is the documentation for start-file-process:

start-file-process is a compiled Lisp function in ‘simple.el’.
(start-file-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
:around advice: ‘start-file-process–with-editor-process-filter’
Start a program in a subprocess. Return the process object for it.
Similar to ‘start-process’, but may invoke a file handler based on ‘default-directory’. See Info node ‘(elisp)Magic File Names’.
This handler ought to run PROGRAM, perhaps on the local host, perhaps on a remote host that corresponds to ‘default-directory’. In the latter case, the local part of ‘default-directory’, the one produced from it by ‘file-local-name’, becomes the working directory of the process on the remote host.
PROGRAM and PROGRAM-ARGS might be file names. They are not objects of file handler invocation, so they need to be obtained by calling ‘file-local-name’, in case they are remote file names.
File handlers might not support pty association, if PROGRAM is nil.
[back]

Question: How do I tell start-file-process to source some bashrc file (e.g. /home/user/.bashrc) before it executes its command?
Attempt; Possibly relevant is tramp-remote-process-environment (I tried setting BASH_ENV=/home/user/.bashrc) but it didn't work).


texts:
Say I have beginning-of-line bound to M-a. At least for me, holding shift gives: M-S-a translates to M-A translates to M-a and emacs doesn't do any shift selection.

It's the same when binding keys -- I gotta bind M-A, binding M-S-a doesn't work. Why is this? Is there any way around it?


texts: Emacs custom major mode with multiple comment types

texts:
I'm trying to write my first (very simple) major mode for Emacs. My goal is to have multiple comment types, but I can't find a way to implement this. Basically, I want my major mode to make highlighted comments as follows

line that comes after #, exactly like in Python
line that comes after !, same as above, but with a different color. Also, I want to be able to add a # comment at the end of this line.
a code block starting with % and ending in end, again with a different color

So far, I have the following in my .el file:

(defvar my-mode-hook nil)

(defvar my-mode-map
  (let ((map (make-keymap)))
    map)

(defvar my-mode-syntax-table
  (let ((st (make-syntax-table)))
    ;; comment style: "# ..."
    (modify-syntax-entry ?# "<" st)
    (modify-syntax-entry ?\n ">" st)
    (setq comment-start "# ")
    (setq comment-end "")
    st))

(defvar my-highlights
  '(("!\\|" . font-lock-function-name-face)
    ("!\\([^<]+?\\)\n" . (1 font-lock-function-name-face))))

(define-derived-mode my-mode prog-mode "my-mode"
  (interactive)
  ;; (kill-all-local-variables)
  (use-local-map my-mode-map)
  (set-syntax-table my-mode-syntax-table)
  (setq font-lock-defaults (list nil nil))
  (set (make-local-variable 'font-lock-defaults) '(my-highlights))
  ;; (set (make-local-variable 'indent-line-function) 'my-indent-line)
  (setq major-mode 'my-mode)
  (setq mode-name "MY MODE")

  (run-hooks 'my-mode-hook))

This works somewhat for # and !, but the text highlight for ! comments does not work if I put a # at the end of the line. Also, it only works after I hit enter at the end of the line, not straight after the ! as I write.


texts:
This is why I ask -- Orgzly on my humble Samsung galaxy S5 can handle a 1.6MB org file with little trouble.

Emacs croaks. I have to kill it and restart. What?!?!?
I also ask because 1.6MB doesn't seem big to me and I have big plans for org-mode, it's a dream come true... almost.

Emacs 24.5.1
Spacemacs 0.200.1 develop
MBA: 1.7Ghz i7, 8GB 1600 DDR3 RAM


texts:
If I set

(ac-set-trigger-key "C-o")

in .emacs, C-o does trigger auto-completion but TAB still does too. It seems that C-o is added to the triggers, while I want it to substitute TAB, so that when I press TAB no auto-completion is performed.

With YASnippet you can do something like:

(define-key yas-minor-mode-map (kbd "TAB") nil)

So that the binding is removed, is there something similar for auto-complete?


texts:
Trying to find in Project with Projectile.. In the Projectile menu i have

Find in project (grep)
Find in project (ack)

Grep works but if i try ack i get..

-*- mode: ack-and-a-half; default-directory: "~/Desktop/proj/" -*- Ack started at Mon Dec 29
16:39:24
 --ignore-dir=.idea --ignore-dir=.eunit --ignore-dir=.git --ignore-dir=.hg --ignore-dir=.fslckout --ignore-dir=.bzr --ignore-dir=_darcs --ignore-dir=.tox --ignore-dir=.svn --ignore-dir=build --ignore-file=is:TAGS --nocolor --nogroup --column --smart-case --env -- audio zsh:1: command not found: --ignore-dir=.idea
Ack exited abnormally with code 127 at Mon Dec 29 16:39:24

I haven't done much to get it to work except install ack-and-a-half and ag.el from MELPA (I'm confused about which I want / how to replace one with the other) but don't know how to proceed or debug - I can't find any documentation

ack and ag both work from the terminal and my homebrew dir has been added to the emacs path

any help for an emacs begginer is much appreciated


texts: How do I set up key bindings for modes in a specific Evil state?

texts:
I have a set of key bindings that I use for both web-mode and php-mode in insert mode (of Evil). So I cannot use set-local-map or something. Because in normal mode, the same keys will then call other commands. So the bindings need to be active in evil-insert-state-map only.

I have the following:

(eval-after-load 'php-mode
  '(progn
     (define-key evil-insert-state-map
       (kbd "C-<next>") (lambda () (interactive) (insert " = ")))
     (define-key evil-insert-state-map
       (kbd "C-<prior>") (lambda () (interactive) (insert "->")))))

(eval-after-load 'web-mode
  '(progn
     (define-key evil-insert-state-map
       (kbd "C-<next>") 'zencoding-expand-yas)
     (define-key evil-insert-state-map
       (kbd "C-<prior>") 'zencoding-expand-line)))

So every time web-mode or php-mode is being loaded, these key bindings will be activated.

The problem is: Suppose I have two open buffers, one in the php-mode and the other in web-mode. When the web-mode buffer is the current buffer and I switch to an another buffer which's in php-mode, the web-mode bindings are still active inside the php-mode buffer.

I tried to solve this problem by using (add-hook 'web-mode-hook [...]) and (add-hook 'php-mode-hook [...]) instead of setting up the bindings in eval-after-load. But that solution doesn't work in this situation.

Any suggestions? I would really appreciate it.


texts: Why is my Imenu not showing function and class definitions?

texts:
I feel like something is wrong with my Imenu setup, because here is what it shows on a simple Python script:

It seems to show some variable definitions, but doesn't have separate entries for the function definitions (the def ... lines), or the classes. What I want is an Imenu that shows just the function and class definitions, in the order in which they appear. So, I want to see something like:
Function: foo(x)
Class: Bar
Function: Bar / __init__(s)
Function: Bar / buz(x, y)

Is that possible at all? Semantic is not an option because it does not parse functions that are typed using Python's type annotations (e.g. a function like def foo() -> None: ... does not appear in the list).


texts: Why does Emacs not enter the debugger when popping a cons twice?

texts:
I wrote some LISP code that was wrong because I was trying to pop a cons twice:

(let ((pair '("a" . "b")))
  (let* ((a (pop pair))
     (b (pop pair)))
    b))

Evaluating this in the *scratch* buffer showed setq: Wrong type argument: listp, "b" in the mini-buffer. I realized that pop requires a list and thus fails the second time; instead, car and cdr work.

I have Enter Debugger on Error enabled. Why doesn't Emacs enter the debugger to show an approximate location of the error?


texts: Make fill-paragraph in python-mode work on paragraph, not whole string

texts:
If I have the following file:

#!/usr/bin/env python3
'''
bla.py

Does this and
that_
'''

..and call fill-paragraph with the cusor at _, then it acts on the entire docstring:

#!/usr/bin/env python3
'''bla.py

Does this and that_

'''

rather than just the second paragraph.

Is there a way to make it act on just the current paragraph, so that the result is:

#!/usr/bin/env python3
'''
bla.py

Does this and that_
'''

(I know that I can select the second paragraph and then call fill-paragraph on the region, but I'd like it to work automatically on the current paragraph, not the current comment).


texts: Looking for a simple way to update an alist without introducing degeneracies

texts:
In my .emacs file I have code like this:

(setq default-frame-alist
      (assq-delete-all 'width default-frame-alist))

(add-to-list 'default-frame-alist
             (cons 'width new-width))

The first expression ensures that the second one does not introduce a "degenerate key" in the alist (IOW, multiple elements having the same car).

That's a javaesque amount of machinery for what other languages achieve with something that looks very similar to this:

default_frame_list["width"] = new_width

Is there a simpler way?

PS: Of course, one could reply with "just get rid of the first expression" (IOW, "don't worry about degenerate keys"), but this does not answer my question.


texts: Removing alignment in LaTeX align environment

texts:
I want to write a very long equation (3-4 lines) in LaTeX. For this equation I want to use align environment. What I don't like is how Emacs formats the LaTeX code: it adds a lot of unnecessary space, something like

\begin{align*}
  \|a+b+c\|^4 & = \left(\|a\|^2 + \|b\|^2 + \|c\|^2 + 2 \langle a, b
                \rangle + 2\langle b,c \rangle + 2 \langle a, c\rangle
                \right)^2\\ &= \left(\|a\|^2 + \|b\|^2 + \|c\|^2 +
                              2\langle a, b\rangle +2\langle
                              b,c\rangle +2\langle a, c\rangle\right)^2
\end{align*}

And it becomes even worse if I edit it. Obviously, it is very inconvenient to edit such a mess in the future. How to force align not to use any automatic formatting and behave like multline, for example?

\begin{multline*}
  \|a+b+c\|^4 = \left(\|a\|^2 + \|b\|^2 + \|c\|^2 +2 \langle a, b
    \rangle + 2\langle b, c \rangle +2 \langle a,c\rangle\right)^2\\
  = \left(\|a\|^2 + \|b\|^2 + \|c\|^2 +2 \langle a, b \rangle +
    2\langle b, c \rangle +2 \langle a,c\rangle\right)^2
\end{multline*}

I use Emacs 26.3 and AuCTeX 12.2.0.


texts: How do I set up smartparens for use with Mathematica comments?

texts:
I've been trying to get smartparens to recognize Mathematica's comments, which have delimiters (* and *), while keeping the default behavior for ordinary parens ( and ). The following configuration isn't working.

(sp-with-modes '(wolfram-mode)
  (sp-local-pair "(*" "*)"
             :unless '(sp-in-string-p)
             :actions '(insert wrap)))

As soon as I type an open paren, smartparens enters a close paren, as it should. I would like to have the active pair turn into Mathematica comments when I type *, as follows,

(|) -> (* | *)

where | is point. Unfortunately, I found this in the smartparens wiki,

  Pairs have to be prefix-free, that means no opening pair should be a prefix of some other pair. This is reasonable and in fact necessary for correct function. For example, with auto insertion of pair "(" ")" and pair "(/" "/)" (which has as a prefix the one paren version), the program wouldn't know you might want to insert the longer version and simply inserts (|). This can technically be fixed with "look-ahead" and then backward alteration of input text, but it will be confusing and probably not very useful anyway. If such functionality will ever get implemented, it will be disabled by default.

I'd like to have this functionality, as it's the same behavior that the Mathematica parser itself exhibits. Can anyone tell me how to do this?


texts: `helm-find-files` with other window as default action

texts:
I would like a helm replacement for find-file-other-window—one that acts like helm-find-files but has helm-find-files-other-window as the default action.

Is there an easy way to do this?


texts: Why does typing '<<<' instead produce '<<EOF\n<' when in shell-script mode?

texts:
Whenever I'm editing a shell script in emacs and type three chevrons to redirect a raw string to stdin, emacs inserts the characters 'EOF' and a new line in between them, so

cat <<< 'some string'

becomes

cat <<EOF
< 'some string'

I can go back and delete the extra characters to get the buffer in the state I want, but this is very obnoxious behavior, and it only seems to happen in shell-script mode, which is usually the only time I type this pattern. Is there way to disable this behavior?


texts: How to insert and populate field in multiple bibtex entries automatically

texts:
I was wondering if anyone knows what's the function in bibtex that allows you to check if a field exist in an entry?

What I am trying to achieve is use the bibtex-clean-entry but as it is, it throws an error when checking @artcile entries without journal field.

1.What I wanna do is go through every entry

2.check if the journal field is existent

3.if not then make one and assign a placeholder

4.finally populate all the entries by assigning a value to the placeholder

At the moment I dunno how to do 2. and 3.

Basically I have the following:

(bibtex-map-entries (lambda key start end) (bibtex-make-field t)))

Which will try to make a bibtex field, but the problem is that it requires to pass in an key=>value, argument (which I don't know how) for the name of the field and its value as well.

Also the above code is not doing any checking whether the field already exist?

Any help to modifying it to do what I want will be highly appreciated it!


texts: Is it possible to include Babel header line when publishing Org-mode files to HTML?

texts: Is it possible to include Babel header lines when publishing Org-mode files to HTML with org-html-publish-to-html? I would like to have the org-mode keywords exported in addition to the code. Ideally I would like to have a choice of what keywords get published (e.g., #+NAME:, #+BEGIN_SRC, but not #+RESULTS). For a bit of background, I have an org-mode file with multi-language code blocks. I would like to show the results from one code block are input into other code blocks. I see there are many options, but apart from "todo", none reference keyword export.


texts: Undesirable Cursor Jump After Movement with M-left or M-right in Term-Mode

texts: When I reposition the cursor in term-mode or ansi-term with M-left or M-right, it always returns to its original position (see animation below). Is this behavior standard? Is there a way to change it so that it behaves as it would in other buffers?


texts:
In Calc I have two bidimensional, Nx1 matrices

' [1 2 3] RET v t RET

if I use the | command I get a 2Nx1 matrix (let's say a vertical stack)
and of course i could

' [1 2 3] RET RET | vt

to get what I want but I have already the Nx1 matrices and I wonder if there is a command to avoid transposing the individual matrices, stacking and eventually transposing another time...

Tia


texts:
I would like to use an idle timer that is local to the current buffer in one of my packages. However, I can't seem to find out how.

How can I create (or fake) the behavior of a buffer local idle timer? Is the only way to call a function that checks (current-buffer)?


texts: Reading info files without knowing their path

texts: If I'm in a terminal, I can just type info glibc and get info about glibc. Since emacs reads info files, it's silly to use M-x term to read info files from within emacs. I know you can use C-u C-h i followed by the path to the info file, but how can I just tell emacs to get info on glibc like I would on the command line?


texts: How can I make a theme use particular face attributes for a given face in a single buffer?

texts:
I'm loading a deftheme theme using (load-theme). I'm very happy with it most cases, but in yaml-mode I'd like to change attributes for font-lock-variable-name-face.
How can I make the theme use different face attributes for it in a single buffer?


texts: python.el: auto save buffer before python-shell-send-buffer

texts: Can python.el be set up in a way that it will automatically save the current buffer when python-shell-send-buffer is called (e.g. by C-c C-c)?


texts: Org links to regex under portable subtree

texts:
Is it possible to have links like this?

[[id:a5e9935a-9b82-480d-9c27-74a71bfac27a::/regex/]]

That is, links to a match under a portable subtree?
This, at least, did not work.

(By portable subtree, I just mean a subtree that has a randomly
generated ID, so that links to it still work after it has been refiled.)


texts: change the privileges of opening a file when it has already jumped to a remote host using tramp

texts:
Good afternoon. To visit the local sudo privilege file, I use the tramp command:

Ctr+f //sudo::/путьКфайлу

Is it possible to open a remote file with sudo privileges if emacs already uses tramp, and the invitation to enter visiting the file looks like:

Ctr+f /ssh:remoteHost:/home/uzvr

It seems to me there should be a team to change the privileges of opening files when emacs is already working with deleted files. Thanks.

Thank you, Michael Albinus, you get a new jump, and you can’t use the fact that you already reached the host. I use an ssh certificate to access the host (it is written in the configuration file, thank you again for this personally), a third-party application forms the command (in this case, my command looks like this:

/usr/local/bin/emacs -eval '
(progn
  (require (quote tramp-sh))
  (let ((args (assoc (quote tramp-login-args)
                     (assoc "ssh" tramp-methods))))
    (setcar (cdr args)
            (append (quote (("-F" "/home/alamd/ПакетыДоступа/al_kuhnia/config")))
                    (cadr args)))))' \
"/ssh:remoteHost: ~"

Next, emacs opens the user folder. It turns out then how can I transfer the configuration file for ssh again to tramp


texts: How to make Alt-h work in Org mode in Spacemacs?

texts:
When inside a table in Org mode, I can press Alt-l to move the column to the right.

But alt-h does nothing.

The same happens when  I try to put the heading one level deeper. Alt-l works but alt-h doesn't, meaning I can add asterisks to the header with alt-l but the opposite is not possible.

How to make it that alt-h works in Spacemacs?


texts: Why do I have to double-press alt/option to get a meta key?

texts:
I'm using Aquamacs 3.3  GNU Emacs 25.1.1 under MacOSX 10.12.6 (Sierra).

It's a fresh install of the operating system and aquamacs. Instead of just doing option-g to get meta-g like I used to, I now have to do option-g option-g to get meta-g. This is annoying.

Anyone come across this problem and solved it?


texts: How to change the mark (*) color in dired mode

texts: I am using the cyberpunk-theme, the * are show in light green and is not visible in hightlighted line. I tried to set dired-mark-face to white. Is there other variables I can set?


texts: Using company-mode completion with read-from-minibuffer

texts:
The following code (mostly coming from here) creates a company-mode back-end and binds TAB to it:

(require 'company)

(defconst sample-completions
  '("procedural" "functional" "high-level" "low-level" "statically-scoped" "dynamically-scoped"))

(defun company-sample-backend (command &optional arg &rest ignored)
  (interactive (list 'interactive))
  (let ((my-completions (copy-sequence sample-completions)))
    (case command
      (interactive (company-begin-backend 'company-sample-backend))
      (prefix (and (eq major-mode 'fundamental-mode)
           (company-grab-symbol)))
      (candidates
       (remove-if-not
        (lambda (c) (string-prefix-p arg c))
        my-completions)))))

(add-to-list 'company-backends 'company-sample-backend)

(define-key company-mode-map (kbd "TAB") 'company-sample-backend)

I have checked that the above works. That is, when I put a regular buffer (such as *scratch*) in company mode, I can invoke completion by pressing TAB and the sample-completions collection is used for completion.

Now I am trying to read a string from mini-buffer with auto-completion. To make sure that the mini-buffer is in company mode, I evaluate:

(defun my-minibuffer-mode ()
  (company-mode 1))
(add-hook 'minibuffer-setup-hook 'my-minibuffer-mode)

Now I try:

(read-from-minibuffer "Prompt: ")

However, what I get is completion from the English dictionary and not from my sample-completions collection. How do I fix this?


texts: Is it possible to do helm-org-in-buffer-heading with matching of inherited tags?

texts:
I like being able to filter by tag and I like to use helm-org-in-buffer-heading helm/ worf-goto worf.

Is it possible to combine them?

I.e, with Worf-goto I can search headings and their tags, but it doesn't list headings that should inherit the tag. e.g

* Emacs tasks :emacs:
** Figure out ultimate macro that will do my work for me
** Make emacs make my coffee in the morning

If I search for ':emacs ultimate', ideally it should match the 1st sub-item, but worf-goto/helm-heading search doesn't. It can either find the line with :emacs: or the line with 'ultimate', it can't match them both.

The agenda view C-c s kinda works. I can first do a search and then narrow down via tags. But this is a 2 step process and it only works on agenda files. I have a lot of non-agenda org files that I'd like to parse with heading/tag combo.

Thoughts?

[EDIT]
At the moment I'm tagging every headings with all the tags (e.g below) and I'm looking forward to the day where I can make use of the inheritance instead.

* Emacs tasks :emacs:
** Figure out ultimate macro that will do my work for me  :emacs:
** Make emacs make my coffee in the morning  :emacs:


texts:
It seems like org-mode doesn't want to load the bullet character y tried putting pretty characters on and toggling between text and org to make it work but everything seems pointless.
Distro emacs: Doom
OS: Manjaro gnome


texts: Make `tab` key insert 5 space characters in Latex Mode

texts:
In Latex mode, the tab key runs the command indent-for-tab-command

From the output of C-h k tab when in Latex mode

I rarely need to indent lines in my Latex files, and so I want to disable this behavior. Also I often find it necessary to insert 5 spaces at a time, when I am writing little snippets of Python or Yaml code in my .tex files.

Is it possible to bind the tab key to be able to insert 5 spaces (but only when in Latex mode)?


texts: How do I enable allout minor mode on Emacs starts up

texts:
Because the allout.el is standard a library, rather than an optional ELPA package, to enable the it (allout minor mode) on Emacs starts for all modes can be as simple as creating a global version of the minor mode like so:

(defun my-turn-on-allout-mode-maybe ()
  "Enable `allout-mode', where applicable."
  ;; Unconditional here, but edit as desired if it turns out
  ;; that you don't actually want this for ALL modes.
  ;; (This function is called in every buffer, when the
  ;; global mode is enabled.)
  (allout-mode 1))

(define-globalized-minor-mode my-global-allout-mode allout-mode
  my-turn-on-allout-mode-maybe
  :group 'allout)

(my-global-allout-mode 1)

thanks to phils' answer from How to redefine the allout prefix keybinding.

Now I have two questions.

Question #1, suppose, just suppose, because I don't know emacs well to give another good example, that allout-mode is a minor mode from ELPA that I installed myself. How to enable it in this case? Would the above still be good?

My main confusing is about timing. From http://www.emacswiki.org/emacs/ELPA#toc6, it says,

  Whenever Emacs starts up, it automatically calls the function ‘package-initialize’ to load installed packages. This is done after loading the init file... So packages are initialized AFTER the init.el is loaded. This means you should NOT put package specific initialization into your init.el except...

So if the installed packages are loaded after loading the init file, then how can I enable them in the init file, when the package is not loaded yet? Would the above still be good?

I meant, once the ELPA packages are installed locally, they would behave exactly like any other locally available library (either from system or from person libs), right? They normally would be required, which means loading a package if it has not already been loaded. The system library are normally autoloaded, which means loading a file only when a function is called. I don't think the ELPA packages cannot be autoloaded, correct? So my anwser would be, the above will still be good, is that correct?

Question #2, now that with above code I've turn the minor mode into a global  mode, how to disable it for a specific mode, say markdown-mode?

I tired this

(use-package markdown-mode
  :mode ("\\.\\(txt\\|markdown\\|md\\)\\(\\'\\|\\.\\)" . gfm-mode)
  :init
  (progn
    (flyspell-mode 1)
    (allout-mode -1)
    ))

but the allout-mode is still on when I open a markdown file.

UPDATE, for the record, for all my questions, I gather all the answers to here.


texts: ESS smart underscore does not work in emacs25

texts:
Previously when I used the underscore key in my keyboard ESS replaced it for the assigment keys <-. In emacs25 that no longer happens.

I have installed the ESS package from MELPA, as well as, it's dependencies. I have the line

;; initialize all packages at startup
(package-initialize)

at the top of my .emacs file.

How can I replace the _ with the <- when I am trying to assign a variable in R.


texts: Flyspell not reading the complete word - FRENCH LANGUAGE

texts:
I am using flyspell for the first time.
For word with "^" inside, it looks like they are read as two separate words.
For example, below, the word "maître" is underlined, and the word proposed start with "t"

And there

I understood from my first research on the web, that it might come from utf-8 not set for ispell.
I tried to change the value of ispell-encoding8-command initially set to --encoding= :
(setq ispell-encoding8-command "--encoding=utf-8" )

but it did not work
Ispell : 3.1.20
Aspell : 0.60.8


texts: Activate a minor mode switching off the other ones in a set of minor modes

texts:
I'm developing a set of minor modes that I use in my LaTeX copy-editing work.
I have, e.g.. a list of three minor modes stored in a variable:
(defvar latex-editing-mode
  '(preamble-editing-mode
    biblio-editing-mode
    proofs-editing-mode))

I need them to be active one at a time. E.g. when I turn-on biblio-editing-mode the other two modes must be turned-off.
I'm trying to write a function:
(defun activate-mode-in-list (MINOR_MODE MINOR_MODE_LIST)
  (interactive)
  (let ((MINOR_MODE_LIST (delete MINOR_MODE MINOR_MODE_LIST)))

(mapcar (lambda (mode) (setq mode nil)) MINOR_MODE_LIST)
(setq MINOR_MODE t)))

I need to use it this way:
(activate-mode-in-list biblio-editing-mode latex-editing-mode)

because I want to use it to write a set of functions to be called with dedicated and consistent keybindings. Eg.
(defun activate-biblio-editing-mode ()
  "Activate `biblio-editing-mode` and deactivate the other ones
setted in the `latex-editing-mode` variable"
  (interactive)
  (activate-mode-in-list biblio-editing-mode latex-editing-mode))

And then:
(require 'preamble-editing-mode)
(global-set-key (kbd "<C-M-kp-0>") 'activate-preamble-editing-mode)

(require 'biblio-editing-mode)
(global-set-key (kbd "<C-M-kp-1>") 'activate-biblio-editing-mode)

;; ...

(require 'proofs-editing-mode)
(global-set-key (kbd "<C-M-kp-9>") 'activate-proofs-editing-mode)

But my activate-mode-in-list function doesn't work as I wrote it. I guess I'm getting lost in quoting stuff because evaluating:
 (setq preamble-editing-mode nil)
(setq biblio-editing-mode t)

works as expected.

Where am I doing wrong?
Is there a better way to achieve my goal?

All I need is a function that activates a specific minor-mode and deactivate some other minor modes. I can store this set of minor modes in a variable.. In my workflow, "in most cases", only one minor mode of this set of minor modes should be active at a time (but in some cases I would have more then one active at the same time. In this case I'd open them in the standard way).


texts: Completion for variables in C using company-gtags, or not Semantic

texts:
I have a working C IDE without Semantic (too slow for me), from instructions here, with completion provided by company-gtags (I think.  Maybe clang does something too?).

Completion at point works for functions throughout the project, but not for variable names.  I.e., if param_n is a global variable, I get no completions for param, even when I force completions.  I expect that gtags knows about param_n, because it shows all of the references to it when I call global -sx param_n from the command line.

How do I get completion, without Semantic, for local and global variables, whenever they are in scope?


texts: How can I adjust the fixed-width of a Neotree buffer?

texts:
Using emacs 24, when I try to use the Neotree package I am having issues with modifying the fixed-width of the window. I believe I have found the responsible chunk of lisp, but changing the value doesn't seem to help on reload.

(defcustom neo-window-width 25
  "*Specifies the width of the NeoTree window."
  :type 'integer
  :group 'neotree)


texts: How to sort habits by priority in the org-agenda view?

texts:
How can I sort habits in the org-agenda first by priority, then schedule + deadline + consistency?

I tried to set the org-agenda-sorting-strategy to various configurations, but ultimately habits are always sorted first by schedule + deadline + consistency followed by priority, the opposite of what I want.

I strongly prefer to avoid modifying the org source code like this SO question does.


texts: How to auto calculate the begin and end lines when including source files in org-mode?

texts:
I have the below in my documentation:

#+INCLUDE: "code/basic.sv" :src systemverilog :lines "14-117"

Here line 14 is where I have class basic extends .. and line 116 is where I have endclass.

Is there a way to auto insert the numbers 14 and 117 (=116+1) so that I don't have to manually update them every time I modify the code/basic.sv?


texts: How to define backslash as keybinding in AUCTeX

texts:
I have inserted the following code in my init file.  This code insert a space+\ (ie, " \") when typing \ in a buffer.

Despite the fact that the function ddd works without problem in any buffer, the shortcut \ doesn't work when the file is in LaTeX mode (AUCTeX).

Is there any solution to solve this problem, i.e. typing \ executes the function ddd? The function ddd is just an example, the same problem occurs for any function I bind to the backslash.

(defun ddd ()
  "Insert a dollar sign with a space in front."
  (interactive)
  (insert " \\"))

(global-set-key (kbd "\\") 'ddd)


texts: How to dump the content of an item in a TODO list on a file

texts:
Suppose that one has a list of items on a file koko.org (hereafter called the org file), as follows:

* heading A

 FOO

* heading B

  BAR

The list contains two items. My objective is to have a macro, preferably within the scope of an item, that will trigger the following actions:

obtain the heading of the current item,
capture the contents of the item on a given buffer, and
save the content of the buffer in a file.

e.g. the first item after the macro is called will save a file text.txt in a directory called A containing the text FOO, and similarly for the second item.


texts:
I have an org-file with a todo list organised by weeks, like the following:

* Sunday
** DONE Ask in StackExchange.
SCHEDULED: <2019-06-28 Fri 13:00-14:00>

* Monday
** TODO Get an answer
** TODO Get solved my problem
* Tuesday
* Wednesday
* Thursday
* Friday
* Saturday

However, suddely and automatically it rearrange eliminating my order by days in a week to the following format:

* Ask in StackExchange
:PROPERTIES:
:LINK:     Go to gcal web page
:ID: 07llhrrtc5s20ea89gqqrs90g5_20190725T210000Z
:END:

<2019-06-28 Fri 13:00-14:00>

* Get an answer
* Get solved my problem

Why is it changing automatically?, and how can I avoid this behavior and keep my order by weeks?

Thanks,

Here is my org-config.

;; ORG MODE
;;
(add-to-list 'load-path (expand-file-name "~/git/org-mode/lisp"))
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
(require 'org)

;; new line at 80th column
(add-hook 'org-mode-hook '(lambda () (setq fill-column 80)))
(add-hook 'org-mode-hook 'turn-on-auto-fill)
;;
;; ORG alert
;;
(setq alert-default-style 'libnotify)
;;
;;; Standard key bindings
;;(global-set-key "\C-cl" 'org-store-link)
;;(global-set-key "\C-ca" 'org-agenda)
;;(global-set-key "\C-cb" 'org-iswitchb)

;;
;;directory of agenda files
;;

(setq org-agenda-files '("~/Documents/Agenda/"))

;;
;; group all elements of agenda
;;
(setq org-agenda-custom-commands
    '(("c" "Simple agenda view"
       ((agenda "")
       (alltodo "")))))

;;; Sync with google calendar
(require 'org-gcal)
(setq org-gcal-client-id "" ;; here Personal_info
  org-gcal-client-secret "" ;; here Secret_key
  org-gcal-file-alist '(("" .  "~/Documents/Agenda/todo.org") ;; email account
                        ))

;;(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
;;(add-hook 'org-capture-after-finalize-hook (lambda () (org-gcal-sync) ))

;;; Org calfw
;;(add-to-list 'load-path "~/.emacs.d/emacs-calfw")
;;(require 'calfw)
;;(require 'calfw-org)

;;; Org-ref
;;;; This is for make available org-ref in Melpa
(add-to-list 'package-archives
         '("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For compatibility
(add-to-list 'package-archives '("gnu" .     "http://elpa.gnu.org/packages/")))
(package-initialize)

(require 'org-ref)

Additional info:
The message when this behavior occurs is:

OAuth token expired. Now trying to refresh-token


texts: What are the conditions when a variable can be both dynamically bound and cause a void-variable issue?

texts:
I get:

Debugger entered--Lisp error: (void-variable implicit-layout-active)

When using a variable declared as dynamically bound:

(void-variable implicit-layout-active)

I thought I cannot get void-variable issue for declared dynamically bound variables. Note that I do not use makunbound. But I do use lexical-binding: t for the module in question. What can this be?

More info here: https://github.com/haskell/haskell-mode/issues/854


texts: How to disable magit on remote files with tramp?

texts:
I'm working with Emacs on windows, I usually work locally, but I want to disable magit when I'm working on a remote file.
I'm trying to add a hook that disables magit when it detects that the file is on a remote server. I tried this snippet but it freezes tramp everytime I try to open a remote file:
(use-package magit
    :ensure t

    :init
    (add-hook
       'magit-mode-hook
       (lambda () (when (file-remote-p default-directory) (magit-mode -1)))))


texts: Control window splitting while opening on files with helm

texts:
I am trying to be able to control where a new window should go, when I use helm-find-files. I am aware of split-height-threshold and split-width-threshold, and it works if I set them to behave appropriately (setq outside the defuns). But what I am trying to do is set them temporarily before calling the function that actually splits the window (here, helm-ff-run-switch-other-window). However, even though these 2 variables have the correct values (using let), the functions don't seem to do anything. Perhaps the code will explain it better:

(defun my/helm-switch-other-window-horizontally ()
  (interactive)
  (let ((split-height-threshold 0)
        (split-width-threshold nil))
    (helm-ff-run-switch-other-window)))

(defun my/helm-switch-other-window-vertically ()
  (interactive)
  (let ((split-height-threshold nil)
        (split-width-threshold 0))
    (helm-ff-run-switch-other-window)))

(define-key helm-find-files-map (kbd "C-c s") 'my/helm-switch-other-window-horizontally)
(define-key helm-find-files-map (kbd "C-c v") 'my/helm-switch-other-window-vertically)

I guess I'm doing something wrong with variable binding?


texts: How do I force a mode on a specific file through special comments

texts:
I have a file called zshrc (not .zshrc). Emacs does not recognize that it must use sh-modeautomatically. I want to put some sort of hint for emacs to pick up and syntax highlight my file accordingly.

how do I achieve that?


texts: Inline verbatim and code with quotes in Org-mode

texts:
In Org-mode I can surround text with = or ~ to place text in inline verbatim or code mode.

However this fails if the text has quotes, and I couldn't find an explanation or workaround in the documentation.

For example:

=hello= Renders as verbatim
~hello~ Renders as code
=hello'= Fails to render as verbatim
~hello'~ Fails to render as code

The only solution that I found so far is inserting invisible characters, e.g. typing C-x 8 <RET> 200b <RET>, as explained in this question.

Why is this (is it a bug?) and how can I avoid this problem without inserting invisible characters?


texts: mwheel-scroll bindings between GUI and terminal?

texts:
Using an Emacs daemon (28, pgtk branch) switching between GUI and terminal, I can't get mouse scrolling to work on both. They work on each individually, but the issue is with the mouse-wheel-{up,down}-event var - it's mouse-4/5 on terminal and wheel-down/up on GUI. This has been documented in bug-gnu-emacs as far back as 2009. I tried:
(global-set-key (kbd "<mouse-4>") (kbd "<mouse-down>"))
(global-set-key (kbd "<mouse-5>") (kbd "<mouse-up>"))

as suggested, but that gave me bad binding in mwheel-scroll.  Trying other things with kbd macros gave me After 0 kbd macro iterations: undefined: Keyboard macro terminated by a command ringing the bell. Any other ideas?


texts:
What's the easiest way to jump to a heading in a datetree programmatically?

I basically want: whenever I open my org file with file+olp+datetree structure to jump to a current day, if there's no heading for the current day, then the latest available one.


texts: Saving undo-tree to restore in next session

texts:
I wanted to know if undo-tree has a feature that saves the undo-tree of a file, and automatically restore it when opened in another session.
I went to the undo-tree doc page, and of course the feature exists, it is called undo-tree-auto-save-history.

My questions are: How should I modify my init.el file in order to have the feature enabled for all kinds of files ? And is it going to auto-restore the undo-tree when opening a file ?


texts: Emacs daemon not working properly, Emacs server runs fine

texts:
Version

GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2016-04-25

Xubuntu 16.04, Linux kernel 4.4

In my .emacs I have the following settings

(require 'server)
(unless (server-running-p)
(server-start))

When I call emacsclient -c -a emacs, it works like a charm. When there is no Emacs instance running in background or in another workspace, Emacs will be called. Otherwise, emacsclient will be called.

But I want to have Emacs running in the background. For that, I use the Emacs daemon.

When calling emacs --daemon, I see my dot-emacs being loaded in the terminal. After that, I call emacsclient -c or emacsclient, but it cannot detect the Emacs daemon/server.

When Googling around, I found this answer: http://www.tychoish.com/posts/getting-emacs-daemon-to-work-right/

So I added it to my commands that it will be called on startup:

emacs -u renefroger(my username) --daemon --eval "(setq default-frame-alist \ '((font-backend . \"xft\") (font . \"[FONT]-[SIZE]\")))" -l ~/.emacs

After a restart, I call emacsclient -nw but it makes it somewhat unusable. I got sometimes the message  Error reading from stdin when I do sometihing like M-x Helm, and the colors are not right, while they're fine the console Emacs with the Emacs server instead of daemon. So I'm puzzled what's going on with the Emacs daemon.

How could I get Emacs daemon working properly?


texts: Problem saving (C-x C-s) files on a NFS drive with emacs 24/25

texts:
Starting with Emacs 24 (using various different versions of Ubuntu and Linux Mint), if I open a file on an NFS drive, modify it and attempt to save it C-x C-s, I get the message of: Saving <filename>..., but the file does not save, and is still marked as having been changed.

If I save the file with a C-x C-w, the file will save, and all subsequent C-x C-s attempts for that file will succeed until the buffer is killed.

This problem does not exist on the same machine/file system if I use Emacs 23.


texts:
When working with files changed on disk, there are two warnings

... changed on disk; really edit the buffer?
... has changed since visited or saved.  Save anyway?

They're useful, but get very impractical when switching branches fort and back (as I commonly do with git).

Is it possible to make Emacs determine that the content hasn't actually changed (or has been restored to a state equals to what's in its Emacs buffer)?

The fix given in the nearly-duplicate solves the first part only. As @Stefan wrote, the second is easy using (set-visited-file-modtime).


texts:
I would like to unbind the space key in the org-agenda. Currently it is scrolling the org-mode file to the currently selected item in the org-agenda (org-agenda-show-and-scroll-up).

I am currently using SPC globally for command, and I would like to SPC to be bound to that function in the org-agenda, instead of org-agenda-show-and-scroll-up.

I have been unsuccessful in unbinding this key so far.

Any idea?


texts: Getting the value of previos field with yasnippet

texts:
Sometimes it would be handy to get the previously entered field values, and process them.

Example: the second field (function name) of this snippet is always the camelCase version of the first field (description) in my workflow.

describe('$1', function $2() {
  $0
});

To write lisp function to do this, one should know how to get the value of the first field.


texts:
Let's say I have the following file shown in Windows File Explorer:

If I enter C-c C-v to copy and paste the file, the file is duplicated and automatically given a name:

We can repeat this to get more duplicates which are also automatically named:

Does a similar command exist for dired? I looked for something like dired-do-duplicate but didn't notice anything like that.


texts: Split window horizontally when calling switch-to-buffer-other-window the first time

texts:
When calling switch-to-buffer-other-window interactive function the first time, the window is split horizontally.
I would like the window to split vertically instead of horizontally by default.
Is it possible to achieve that?


texts: isearch, but not past the nth line of the buffer

texts:
I'm doing an Isearch on a large file. I'm on line 30, starting the isearch.

Is it possible to tell Emacs to do the Isearch but consider line 343000 as the end of the file.

The file has 1,000,000 lines.


texts:
I am syncing AUCTeX with Sumatra PDF on MSWindows. I used the instructions in  https://www.barik.net/archive/2012/07/18/154432/ (I write here the setqs instead of customization)

(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
  '(("Sumatra PDF" ("\"C:/bin86/SumatraPDF/SumatraPDF.exe\" -reuse-instance"
                      (mode-io-correlate " -forward-search %b %n ") " %o"))))
 (setq TeX-view-program-selection
      '(((output-dvi style-pstricks) "dvips and start") (output-dvi "Yap")
       (output-pdf "Sumatra PDF") (output-html "start")))

However, when there is a space in the file name (e.g. "example 1.tex"), the syncing has problems: when from Emacs I do CRTL-c CRTL-v, it opens both the the file "example 1.pdf" and a dummy "123" file, where 123 is the line number in the source file.

Any suggestions on how to solve this problem?


texts:
I am using the following init file to download and load packages from melpa-stable in fresh Emacs installations:

(require 'package)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(setq use-package-always-pin  "melpa-stable")
(package-initialize)

;; Download use-package
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Reduce load time
(eval-when-compile (require 'use-package))

;; Get packages
(use-package foo :ensure t)

;;... etc

I have two questions/problems.

First: (eval-when-compile (require 'use-package)) is  suggested by github.com/jwiegley/use-package, to speed-up the init, but to me it gives the  non-critical error:

Eager macro-expansion failure: (file-missing "Cannot open load file" "No such file or directory" "use-package")

Secondly, while use-package is proposes a safe approach to automatically install packages, the author does not tell how to do same with use-package itself. The test (package-installed-p 'use-package) works, but since it requires initialising all packages, I suspect it can slow-down the init, and wonder if there is a faster way.

Edit

It seems that after switching from  https://stable.melpa.org/packages to https://melpa.org/packages the eager macro-expansion failure disappeared from the  Messages buffer.


texts: How to have org-babel treat the first line of a table result as a header?

texts:
I'm dealing with a trivial shell script that invokes the mysql binary on a remote server, and having org-babel capture its results as a table.

With sensitive information scrubbed, the source block resembles

#+BEGIN_SRC sh :results value table
#!/bin/sh
ssh remote.host 'mysql db -e "SELECT foo,bar,baz FROM stuff"'
#+END_SRC

and its result is formatted as tab-separated values, the first row of which is a header naming the columns:

foo^Ibar^Ibaz
value^Ivalue^Ivalue
value^Ivalue^Ivalue
⋮

Org-babel correctly interprets this result as a table. What it doesn't do, and I haven't been able to figure out how to get it to do, is treat the first row of this result as a header. More specifically, I want there to be an hline automatically inserted after the first row, so that I can pass just the values to downstream code blocks, without having to have the code in them explicitly filter out the first line.

I'm (almost) sure there is a fairly trivial way to do this, because I've seen examples in other questions on Emacs SE of code block result tables which (appear to be) automatically formatted the way I want mine to be. I just haven't been able to find how to do it for myself in the org-babel documentation.


texts: Displaying contents of another file in an Org-mode buffer

texts:
I have a file whose contents I would like to view dynamically from a generic Org-mode buffer.

For example, suppose I have a file called data.csv, and I'd like to display some of its contents when I visit study.org. To make up one way that this might look, study.org might appear as follows:

# -*- mode: Org; coding: utf-8; -*-
...
#+INCLUDE: "data.csv" :head 5
#+BEGIN_INCLUDE
id,name,count
1,recursion,48
2,exercise,55
3,ambrosia,85
4,division,16
#+END_INCLUDE
...

I see that someone has asked this question in the context of the Org-mode export
 mechanism (How to embed external file contents in org file?), but I don't see a way to include external file content in an Org buffer.

Does Org-mode support this sort of thing?


texts: Yasnippet - No snippet tables active/ YASnippet tables empty

texts:
In .emacs, I bound the key for yasnippet as,

(define-key yas-minor-mode-map (kbd "C-SPC") 'yas-expand)

In a buffer with python as major mode and yasnippet, autocomplete as minor mode, yasnippet doesn't expand on C-SPC.

Now, i started doubting if there are any snippets available. I did C-c & C-v (or) Visit Snippet File and it gives alarm, No snippet tables active.

How to add snippets to a major mode?


texts: How do I get a string displaying the keypress of the function (like where-is shows)?

texts:
(where-is 'zap-to-char) ;; Prints ("zap-to-char is on M-znil")
(where-is-internal 'zap-to-char) ;; [134217850] ;;; this number seems like junk to me!

I would like a function that returns M-z I imagine it would be something like (keypress-of 'zap-to-char).


texts: How can I display only current png and hide others in org-mode?

texts:
I have a lot of inline images and I want to disply only 1 in buffer and hide others while viewing.
With M-x org-toggle-inline-images I can do this for the entire buffer, but it's too much for me.
So, how can I do this?
Update:
With M-x org-open-at-point I can preview the image, but I would like to be able to compare multiple images.


texts: M-RET to open buffer in new frame in helm-mini?

texts: Is it possible to add a key binding M-RET to helm-mini which would open the selected buffer in a new frame instead of in the current window?


texts: Smartparens: do not insert parenthesis pair when point is at the beginning of word

texts:
How can I make smartparens not to insert a parenthesis pair when the point is at the beginning of a word? I only want it to insert the opening parenthesis.

This is my setup:

(use-package smartparens-config
  :ensure smartparens
  :diminish smartparens-mode
  :config
  (progn
    (smartparens-global-mode 1)
    (show-smartparens-global-mode 1)
    (setq
       smartparens-strict-mode nil
       sp-autoinsert-if-followed-by-word nil
       sp-autoskip-closing-pair 'always
       sp-base-key-bindings 'paredit
       sp-hybrid-kill-entire-symbol nil)
    ))

As you see, I have set sp-autoinsert-if-followed-by-word to nil, as the documentation recommends, but to no avail.

See the animated gif here:

How can I fix this?
Thanks.


texts: Error message "Symbol's function definition is void: org-link-types" when I open a .org file

texts:
I tried to get the "capture"-Feature to work.

I did the following things:

Installation of the newest Version of the Org mode
(now the version 8.2.10)
To get the capture feature work i added to my .emacs:

;;https://stackoverflow.com/questions/3622603/org-mode-setup-problem-when-trying-to-use-capture

;(add-to-list 'load-path "/nils/home/emacs.d/org-7.01h/lisp")

(require 'org-install)

(require 'org) ;; maybe this line is redundant

;; Verzeichnis für "org-capture" festlegen
 (setq org-default-notes-file (concat org-directory "/notes.org"))

(define-key global-map "\C-cc" 'org-capture)

After these changes i get the error messageSymbol's function definition is void: org-link-typeswhen I open a .org file.

I don't know how to handle this error message.


texts: How can I make icomplete/ido behave like iswitchb?

texts:
Emacs has recently (between 24.0 and 25 ish?) removed iswitchb in favor of some combination of ido and icomplete mode, which I've seen claims are 99% compatible; which I can live with, I don't have any sort of fancy custom hooks or anything just a few excludes here and there. But I can't seem to figure out how to make the "new" modes work the way iswitchb did.

When trying to open a new file with C-x f or C-x C-v I often get stuck with extra garbage on one or both ends of the path I'm trying to navigate to, (either the path prefix is in a weird green mode and behaves oddly when trying to navigate or edit characters or text persists to the right of the point and interferes with suggestions. Or at times I only get suggestions for directories even when there are files present (I have multiple times had to type the entire path and file name and hit enter to open a file as it wouldn't complete at all).

So how do I get the iswitchb style behavior back?

Here's a specific repeatable occurrence of one problem: I have a file open in a buffer, and hit C-x C-f to find a new file, the path to the buffer's current file's directory is pre-filled in the mini-buffer and is the colour of the mini-buffer prompt instead of the colour of the text you type (green instead of white for me), if I paste/yank/whatever in a relative path, the new text is white and ido (or icomplete or whatever is handling the completion in this case) cannot find the file. What's more; often there is some overlap at the end of the pre-filled portion of the path and the new text added, so I need to edit at that point, however pressing alt-b deletes directories off the end of the pre-filled section instead of moving the point and the new text is lost too.

eg:

open file at ~/Developer/lisp/cool_file.el
copy the path to another file in another terminal tab or where-ever.
eg: ruby/other_cool_file.rb
press C-x C-f in emacs to find a new file
the mini-buffer will show the following:
Find file: ~/Developer/lisp/ in the mini-buffer's "prompt" colour
paste in the new path
Find file: ~/Developer/lisp/ruby/other_cool_file.rb [No match]
the pasted path will be the regular colour of mini-buffer input and the file will not be found even if the path is correct as is. (hitting return will clear the pre-filled path completely and replace it with the pasted path, which won't find anything either.
if there needs to be some change made at the point between the two styles of text in the mini-buffer, pressing alt-b to get to that point will not move the point as expected but instead remove the rightmost prompt-coloured directory from the pre-filled path and delete the new path that you pasted in.

Obviously I'd like to have the file be found when the path is correct as entered and be able to navigate the mini-buffer as normal.


texts: Highlight variables without $ inside (( )) when in sh-mode?

texts:
Is there a way to modify sh-mode to highlight variables inside a double parentheses construct when not using the dollar sign prefix?
For example I want the i to be highlighted in ((i++)) without the need of writing $i.


texts:
I'm trying to change the color of this part of the UI (top heading bar) in my theme file:

Does this have a specific name that I could use to change its color?

Other parts of the interface are referred to like so, but this element isn't there:

   `(cursor ((t (:background ,atom-one-dark-accent))))
   `(fringe ((t (:background ,atom-one-dark-bg))))
   `(region ((t (:background ,atom-one-dark-gray))))
   `(highlight ((t (:background ,atom-one-dark-gray))))
   `(hl-line ((t (:background ,atom-one-dark-bg-hl))))
   `(vertical-border ((t (:foreground ,atom-one-dark-mono-3))))
   `(secondary-selection ((t (:background ,atom-one-dark-bg-1))))
   `(query-replace ((t (:inherit (isearch)))))
   `(minibuffer-prompt ((t (:foreground ,atom-one-dark-silver))))


texts: Spacemacs - What does C-c do (what things are inside this menu)?

texts:
I'm learning emacs/spacemacs right now and I'm slightly confused about the C-c binding.

Pressing it opens a menu with many helpful things that I cannot reach otherwise (it seems like it at least). I'm also confused what the difference is to , which opens the major mode commands.

Here's a concrete example: I'm in org-mode. Using , I can access many features that this major mode offers, I can add stuff, manipulate text, and open the agenda. But if I want to, for example, add the current file to the agenda (via org-agenda-file-to-front) I have to press C-c [. I can't find this command within the major mode bindings in the , menu.

Why are some things within C-c and some within , if they do belong to the same major mode? And what is the purpose of C-c in general? What stuff is being put there?


texts: Sum org-mode table column based on other column

texts:
I have this org-mode table:

| Category         | Category Budget | Needs Transfer |
|------------------+-----------------+----------------|
| Rent             |            3000 | t              |
| Internet         |             125 | t              |
| Food             |            1000 |                |
| Coffee           |             500 |                |
| Cellphone        |             120 | t              |
| Cigarettes       |             100 |                |
| Total            |            9945 |                |

I want the "Total" row, in the "Needs Transfer" column, to show the sum of all of the budgets that have "t" in their "Needs Transfer" column.

I already tried this solution to no avail:

@>$3 = '(apply '+ '(org-lookup-all "t" '(@2$3..@-1$3) '(@2$2..@-1$2) 'string=));E


texts:
Is it possible to use the control key to exit Evil's insert mode? I'm currently using the following code to do it with TAB, but since control only seems to work as a modifier key, I'm not having any luck with it.

  ;; Map single control to ESC
  (with-eval-after-load 'evil-maps
    (define-key evil-insert-state-map (kbd "TAB") 'evil-force-normal-state))

Any thoughts?


texts: Does rx macro work with underscore in character classes

texts:
I'm a little confused by the fact that underscore does not shown in the character class.

ELISP> (require 'rx)
rx
ELISP> (rx (any "A-Z" "_"))
"[A-Z_]"
ELISP> (rx (any "A-z" "_"))
"[A-z]"

Expected result is "[A-z_]" but actual is "[A-z]".

But the test shows curious results for me:

ELISP> (string-match-p (rx (any "A-z_")) "9")
nil
ELISP> (string-match-p (rx (any "A-z_")) "_")
0 (#o0, #x0, ?\C-@)

I would like to clarify 2 things:

Is it correct to use (any "A-Z" "a-z" "_") to match "_" string?
Should I use (any "A-Z" "a-z" "_") or I can safely use (any "A-z"
"_") to match "Abc_Def" string


texts: Make Emacs systemd service kill when logging out/shutting down

texts:
I am trying to use desktop-save-mode together with emacs daemon.

;; save desktop before quitting
(add-hook 'kill-emacs-hook (lambda () (desktop-save "~/.emacs.d/")))

But when I log out of the graphical session (KDE/SDDM) or shut down/reboot, emacs doesn't automatically save current desktop, and leaves .emacs.desktop.lock intact.

I thought about defining a shortcut that execute "(kill-emacs)" and then bring leaving options up, but then I have to exclusively use this one to shutdown, which is not good in case other methods are needed.
Or bind (kill-emacs) to a key, but sometimes I only temporarily close Emacs using meta + f4 or C-x C-c, then quitting without remembering to save the desktop.

Currently, I'm struggling to modify a systemd service as Arch Wiki suggests:

[Service]
Type=simple
ExecStart=/usr/bin/emacs --fg-daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure
[Install]
WantedBy=default.target

But "ExecStop" is executed only when the service is manually stopped, leaving desktop unsaved after logging out.

Or perhaps is there a way to save desktop every time a buffer is close? I tried

(add-hook 'kill-buffer-hook (lambda () (desktop-save "~/.emacs.d/")))

but it didn't work.


texts: list hosts of ssh config file with helm when using ssh.el

texts: I use ssh-mode when I need to work on remote hosts. As I only establish ssh connections to hosts, that are stored in my ssh config file I want this list of hosts to be displayed in a helm-buffer.


texts:
I'm trying to align

 4000 1 2                 4000  1     2
  11 1 44          =>     11    1     44
  1  0000 999             1     0000  999

as described at http://emacswiki.org/emacs/AlignCommands

However, typing in C-u M-x align-regexp, and accepting all defaults, makes no modifications - my emacs minibuffer is just stuck on Repeat throughout line? (y or n) y and I need to press C-g. Am I using the command incorrectly or is there something wrong with my emacs (emacs version 22.1.1)


texts:
I am using Xah Fly Keys.

How should I change the function one of Xah Fly Keys key bindings calls?

For example when in Xah Fly Keys command mode space c . calls the find-file function but I would like it to call the helm-find-files function instead.


texts: Why is my function not identifying the end of the region correctly?

texts:
I have the following function, adapted slightly from here:

;; Insert text around a region. In this case, it's
;; the LaTeX code environment from the listings package
(defun wrap-code (start end)
  "Insert a \begin{code} and \end{code} around a region."
  (interactive "r")
  (save-excursion
    (goto-char start) (insert "\\begin{code}")
    (goto-char end) (insert "\\end{code}")
    ))
;; Assign its shortcut
(global-set-key (kbd "C-c p") 'wrap-code)

If I then select a region and apply my function, it inserts the \end{code} at the wrong place:

\begin{code}while :; do
      echo this is\end{code} a test
done


texts: Counting sub-headings in org-mode using elisp

texts:
I'm wondering if there is a good method of counting subheadings of a particular heading in org-mode.  For example, with the following, return 4 (non-recursively) or 7 (recursively).  Note that I don't want to use keywords (ex: TODO) and [/] syntax (https://stackoverflow.com/questions/13372550/orgmode-show-number-of-children-under-heading); I just want to calculate it programmatically using elisp.

I'm hoping that I'm just missing a useful org function.  Otherwise I may resort to counting results of a regex search using the outline patterns of levels ^\\*{n} bounded by the heading and org-forward-heading-same-level.  This is messy and I'd like to do it the "org way" in case org mode ever ignores heading patterns found in source blocks or edge cases I haven't considered.


texts: Using result of an Elisp function as input to replace-regexp in interactive mode

texts:
I am using replace-regexp interactively. Can I programmatically refer to a match or otherwise interpolate values in the replacement string? In Ruby, for example, it is easily done, by using the #{ <code> } syntax.

For example: Lets say that I have a string which looks like "GClass::DhF". I want to remove the substring "::Dh", replace it with whitespace, and convert to a lowercase the first character that appears after "Dh". So, for example, "GClass::DhF" will be converetd to "GClass f", and "GClass::DhY" will be converted to "GClass y". The idea is that instead of inputting GClass \1, I input what in LISP would be (strcat "GClass " (lowercaseString \1)).


texts:
Any other shell besides eshell and shell in Spacemacs with Emacs v25.1.1 (GUI version) looks like this:

To compare, the terminal in iTerm looks like this:

The font that I use in my terminal is exactly the same font that I use in Emacs, so I really don't know what's going on here. The settings for the shell layer are pretty normal:

(shell :variables
       shell-default-shell 'multi-term
       ;; that's where the screenshot is from, but
       ;; the problem occurs with term and ansi-term as well.
       shell-default-position 'bottom
       shell-default-height 30)

And, as I mentioned in the title, I'm using fish.

I would love to provide more details, but I don't really know what details are relevant in this situation, being very much a noob. I would really appreciate some help if someone's encountered the same situation.

Thanks a lot in advance!


texts: Make consistent syntax highlighting of LaTeX source blocks

texts:
Org manual's solution for syntax highlighting of org-babel code blocks is to turn on native fontification with

(setq org-src-fontify-natively t)

works well for LaTeX code enclosed in blocks with

#+BEGIN_SRC latex

but not for blocks with:

#+BEGIN_LATEX

Is there a way to make both types of LaTeX source blocks use the same LaTeX syntax highlighting scheme/setting?


texts: Running Emacs as a client does not load my settings

texts:
I'm using the new systemd daemon option with Emacs 26. I have a problem, though. If I open a client instance (emacsclient -c) no config files (my .emacs) are loaded. So I don't see the usefulness in running Emacs as a client.
Can somebody cast some light on this?


texts: Any way to have emacs shell pass the TAB into a readline command running inside it?

texts:
Eg. when you're running nice things like Perl or Ruby REPLs, you have code/command completion exposed via GNU Readline. What I want to do is set some elisp/env variable when entering/exiting such a program to indicate that I want shell-mode to pass the TAB key onto those programs.

Note that C-q TAB also does not work, so I think that Readline is also ignoring it because TERM=dumb, but setting it to eg. vt100 also doesn't do the trick, so it might even be looking at EMACS=t.


texts: How do you disable the buffer end/beginning warnings in the minibuffer?

texts:
I see that I can do something like this:

(defun limit-warnings ()
  (set (make-local-variable 'warning-minimum-level) 'fatal))

(add-hook 'minibuffer-setup-hook 'disable-warnings)

(Sorry for syntax errors; I'm not very familiar with Lisp and the above is just an example.)

How do I combine that with warning options to disable warnings from only the minibuffer? (For example, the minibuffer doesn't need to tell me that I've hit the end of the buffer or that the M-x: prompt string is read-only.)

I tried describe-variable with warning-minimum-level and there was no such variable defined.


texts:
I often edit articles in web-mode (using PHP). Is there some way of fontifying HTML entities (like &#8211;, &eacute;, and so on)? I'd like them to be a lighter color so that they're easier to see.

I've tried changing the font-lock settings, but the font-lock code in web-mode.el is confusing to me since it deals with lots of different web-mode flavors. (I only really care about the PHP mode, if that makes things easier.) I've  tried the following, to no avail:

(add-to-list 'web-mode-html-font-lock-keywords
             '("\\&#x?[0-9a-fA-F][0-9a-fA-F]*;?" . font-lock-comment-face))

(add-to-list 'web-mode-php-font-lock-keywords
             '("\\&#x?[0-9a-fA-F][0-9a-fA-F]*;?" . font-lock-comment-face))

I have a feeling I'm just not fiddling with the right variable, but I'm not sure  how to find out which one is right.

Update:

Thanks to @fxbois, it's now super easy: in your config, just do

(setq web-mode-enable-html-entities-fontification t)

and customize the face web-mode-html-entity-face.


texts: How to avoid showing gofmt fail error when saving go code every time in Emacs

texts:
Using Spacemacs and its go layer.

Using Tramp in Emacs ssh to remote server to edit go file. After saving the file, it will check the syntax with gofmt . But every time it shows the error below:

I have tried install these packages at localhost as official guide:

go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/goimports

go get -u -v github.com/alecthomas/gometalinter
gometalinter --install --update

  https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/go

Also set (go :variables go-use-gometalinter t)(or (setq gofmt-command "goimports")) in the ~/.spacemacs file. But not work. Indeed, there aren't go runtime at remote server where go source exist.
So where it looking for and went a alert? How to avoid it?


texts:
windows 10, emacs 26.1

Suppose I open 10 files. And then restart Emacs.
After restart I need to see what files (recent) I was open before. Is it possible to show some buffer that contain name of this 10 files?


texts: Org mode: refile to other files does not work

texts:
I want to be able to refile tasks and todos not only between different headings within a singel org file, but between headings in several org files. To accomplish this I use the following code:

(setq org-refile-targets '(
   (nil :maxlevel . 2)             ; refile to headings in the current buffer
   (org-agenda-files :maxlevel .2) ; refile to any of these files
    ))

However, when trying to refile a task with the key  C-c C-w I get the following error message:

"Wrong type argument: numberp, (0.2)"

What is wrong with my code? or is something else lacking?


texts: How to create face that "passes through"?

texts:
What is the way to define a face that does nothing but "pass through" properties of the text it is applied to?

E.g. in the quick-peek package, quick-peek-background-face is applied to all text passed to quick-peek-show. I'd like quick-peek-background-face to do nothing but allow the properties of the text it's given to show.

Example:

The following has face font-lock-doc-face if we comment out this offending call to font-lock-append-text-property:

(quick-peek-show (propertize "foo" 'font-lock-face 'font-lock-doc-face))

Is there a value to quick-peek-background-face can be set to such that it allows font-lock-doc-face to pass through?


texts: The text in my modeline fits exactly in the modeline, I would like to have some more padding above and below the text, couldn't find an option for it and don't know much about text properties in Emacs. How can I achieve that?


texts:
I used the command matlab-shell for opening a new MATLAB instance inside emacs. How can I have a functionality similar to the of MATLAB which allows to see at once the most recent commands and to navigate through them?
I would like to have something with the appearance of an autocomplete dialog, showing the most recent commands.


texts: Evaluate org-babel header arguments consistently

texts:
Consider the following org-babel code block:

#+BEGIN_SRC R :session *R* :dir ~/_test
getwd()
#+END_SRC

When I C-c C-c on my source block, I get the following result, as expected:

#+RESULTS:
: /Users/.../_test

But now if I now open the block with org-edit-special and place point on getwd() and run ess-eval-line (or ess-eval-region) my header arguments are completely ignored and R spits out my default working directory:

/Users/.../org

What's more, header args like :dir are only evaluated the first time that the block is executed. So if I want to work through my code line-by-line in org-edit-special and then I return to org-mode and run org-babel-execute-src-block the :dir argument will not get passed into the *R* interpreter.

I would like to make this behavior consistent so that:

Header args are evaluated and passed into the environment every time the code is executed.
Arguments like :dir or :var etc. are captured and passed into the interpreter, whether the code is first run as a block or accessed line-by-line through org-edit-special.

Any thoughts?


texts: Indicate depth of org-mode header level?

texts:
Q: is there a way to indicate the depth of an org header by number?

I often use deep nests of org headers, e.g.:

* header 1
** more
*** still more
**** yet more
***** still going
****** don't judge me
** another subheader
*** here we go again
**** sweet cuppin' cakes
***** puppies

It's easy to lose track of the depth of the header after third or
fourth level.  Is there a way to get a visual indicator of the
depth (maybe with an overlay?) somewhere on the header?  For
example, an overlay over the first * to indicate the numerical
level, as with the following hypothetical:

1 header 1
2* more
3** still more
4*** yet more
5**** still going
6***** don't judge me
2* another subheader
3** here we go again
4*** sweet cuppin' cakes
5**** puppies


texts: Fold source blocks when hiding their entries?

texts:
Q: how do I make source blocks fold automatically when I hide the contents of their entry?

I'd like source code blocks to fold automatically whenever I hide an entry so that they're always out of the way until I specifically want to see them.  Out of the box, however, their visibility seems to be independent of their home entry's visibility.

For example, if I have:

* An entry
  #+begin_src R
    x <- 1:10
  #+end_src

Some descriptive text.

I can toggle the visibility of the source block with TAB when point is on the begin_src line.  However, when I hide (fold) the entry and then show (unfold) it again, the source block seems to remember it's prior visibility state: if it was visible/open, it will be visible when I show/unfold the entry, and if it was invisible/closed, it will be invisible/closed when I show/unfold the entry.

I want to fold/hide my source blocks automatically whenever I fold/hide the entry that contains them.  How do I do that?

PS I'm just now learning how to use source blocks, so I may be missing an obvious solution.  Apologies if so.


texts:
im running emacs 26.1 on debian with xfce, and have no alternative input methods installed.

my compose key recently stopped working in emacs. i get the dreaded <Multi_key> is undefined error.

i'm aware of:

https://stackoverflow.com/questions/10120590/how-do-i-get-compose-key-work-in-emacs and

Compose key in Emacs: <Multi_key> is undefined.

but for me the solutions suggested there do not work. my XMODIFIERS is empty by default. and setting it to =@im=none or ="" doesn't work. setting include "%L" in .Xcompose does not work. running GTK_IM_MODULE=xim emacs -Q doesn't work.

i recently changed a bunch of custom set faces in my emacs init.el which i thought could have caused the issue, but it is also present if i load emacs with no init file.

my compose key is set with setxkb in .xsessionrc. i recently moved it there from another dot file. i thought the move could also have interfered somehow but compose works fine in all contexts except emacs. and i guess the multi_key error means the key is actually mapped in emacs, just not working.

i'm a little confused as to how this cd be a bug it it was working for ages then suddenly stopped. to me that suggests user ruining something, which is usually the case with me! but in this case it is present without my init.el file.

i just found out about C-x 8 but the whole benefit of having a compose key is session-wide compose sequences. i don't want to have to learn two sets.


texts: Calculating cursor position excluding the overlay after-string

texts:
ISSUE:  An overlay after-string at the end of a wrapped line is preventing the function previous-line from moving the cursor directly upwards in a vertical line.

QUESTION:  How to modify the following code snippet so that it essentially excludes the overlay after-string, when point is at the end of the line?

(cons (/ (float (car (posn-x-y (posn-at-point)))) (frame-char-width)) (window-hscroll))

DETAILS:  I have a custom minor-mode that places an overlay after-string at the end of the line, which generates a horizontal overlay stretching from the end of the line to the right edge of the window.  That overlay after-string is causing a conflict with line-move-visual, which is used by previous-line.  When the cursor / point is at the end of the line, the function previous-line should move the cursor directly upwards in a vertical motion when multiple wrapped lines exist.  When the cursor is at the end of the line, it looks like it is a substantial horizontal distance from the right window edge -- however, the overlay after-string causes the above-mentioned code to return a value for the cursor position at the far right window edge.  Consequently, the cursor moves to the visual-end of the preceding wrapped line -- instead of moving directly upwards in a vertical motion aligned with the end of the line.

STEP ONE -- Beginning Position at End of Line:

STEP TWO -- UN-desired Effect:

Desire Effect -- After Step One

In the event that anyone would like to duplicate the overlay after-string at the end of the line, here is a scaled down example of what is depicted in the screen-shots above.  The code works just by pasting it into the *scratch* buffer and typing M-x eval-buffer RET

(defvar my-eol-ruler nil
"A horizontal ruler stretching from eol (end of line) to the window edge.")
(make-variable-buffer-local 'my-eol-ruler)

(defvar my-eol-pilcrow nil
"A pilcrow symbol placed at the end of every line except the current line.")
(make-variable-buffer-local 'my-eol-pilcrow)

(defsubst col-at-eovl ()
  (save-excursion
    (let ((movement-indicator (vertical-motion 1)))
      (when (= movement-indicator 1)
        (backward-char 1)))
    (- (current-column) (progn (vertical-motion 0) (current-column)))))

(defun my-eol-ruler-function ()
  (let* (
    (opoint (point))
    (window-width (window-width))
    (window-start (window-start))
    (window-end (window-end nil t))
    (col-eovl (col-at-eovl))
    (my-current-line-length (- (- window-width col-eovl) 3))
    (pilcrow
      (propertize (char-to-string ?\u00B6)
        'face '(:foreground "red")
        'cursor t))
    (pilcrow-underlined
      (propertize (char-to-string ?\u00B6)
        'face '(:foreground "white" :underline "blue")
        'cursor t))
    (underline (propertize (char-to-string ?\u2009)
          'display `(space :width ,my-current-line-length)
          'face '(:underline "blue")
          'cursor t)))
  (when (or my-eol-ruler my-eol-pilcrow)
    (dolist (description `(
        ,my-eol-ruler
        ,my-eol-pilcrow ))
      (remove-overlays (point-min) (point-max) 'after-string description)) )
  (setq my-eol-ruler (concat pilcrow-underlined underline))
  (setq my-eol-pilcrow pilcrow)
  (save-excursion
    (end-of-line)
    (overlay-put (make-overlay (point) (point)) 'after-string my-eol-ruler ))
  (save-excursion
    (goto-char window-end)
    (while (re-search-backward "\n" window-start t)
      (let* (
          (pbol (point-at-bol))
          (peol (point))
          (col-eovl (col-at-eovl)) )
        (when
          (or
            (< opoint pbol)
            (> opoint peol))
        (overlay-put (make-overlay peol peol) 'after-string my-eol-pilcrow))))) ))

(add-hook 'post-command-hook 'my-eol-ruler-function)


texts: Delete some matches of an incremental search

texts: I use C-s for sequential searching. When I want to delete the current match, backspace will go to the previous match instead. How can I delete the current match?


texts: How to find hook running after last line of code?

texts:
I have a repeating habit such as:

** TODO some habit
SCHEDULED: <2020-05-22 Fri 08:00 .+1d>
:PROPERTIES:
:STYLE: habit
:CREATED:  [2020-05-08 Fri]
:LAST_REPEAT: [2020-05-21 Thu 10:07]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2020-05-21 Thu 10:07]
CLOCK: [2020-05-21 Thu 10:04]--[2020-05-21 Thu 10:06] =>  0:02
:END:

I coded this shortcut, where I commented out my function to clock in and out:

(defun my-org-clock-and-mark-done ()
  (interactive)
  (message "start")
  (org-back-to-heading)
  ;(my-org-clock-in-and-out nil)
  (org-shiftright)
  (message "end")
  )

The result in the *Messages buffer is:

start
Entry repeats: SCHEDULED: <2020-05-22 Fri 08:00 .+1d>
end
Note stored
Entry repeats: SCHEDULED: <2020-05-22 Fri 08:00 .+1d>

I suspect that Org mode has a hook that runs after my last line of code, in this case when a repeating cookie is changed, and shows that change message twice.

How can I find and disable that hook?

Update: Following the answer by phils, I added a debugger with (setq debug-on-message "Note stored") so it catches only the second occurrence. It shows these functions, neither of which I could find in the list of hooks, which I found thanks to Muihlinn's comment. The list of calls is below and has two recursive edits, which I find odd:

  org-store-log-note()
  org-add-log-note()
  recursive-edit()
  debug(error ...)
  message("%s" #("Entry repeats: SCHEDULED: ..."))
  org-store-log-note()
  org-add-log-note()
  recursive-edit()
  debug(error #("Entry repeats: SCHEDULED: ..."))
  message("%s" #("Entry repeats: SCHEDULED: ..."))
  org-auto-repeat-maybe("DONE")
  org-todo(right)
  funcall-interactively(org-todo right)
  call-interactively(org-todo)
  org-shiftright()


texts:
How to automatically save all org files after marking a repeating item as DONE in the org agenda? I'm using this to automatically save my org buffers after every change to TODO status:

(advice-add 'org-todo :after (η #'org-save-all-org-buffers))

(Where η ignores all arguments and calls the given function.)

This however doesn't work for repeating tasks, scheduled like this:

SCHEDULED: <2016-04-22 Fri +1d>

The org document is still modified after changing the state from TODO to DONE. I've tried a number of hook variables and methods, all without success.


texts:
M-x shell has been my friend for decades, and I've always been comfortable even sympathetic with his insistence on being a dumb terminal (i.e. TERM=dumb).  But recently I've found my self setting LC_ALL by hand so that python won't default to ASCII on its standard streams.  I vaguely recall having similar problems at other times with ruby and perl.

So, my question: What is a good approach to setting things up so I don't have to set LC_ALL by hand?  For example, should I just slam this in shell-mode-hook?


texts: Running multiple emacs versions with homebrew

texts:
Perhaps this is more of a homebrew question, but I imagine someone here knows the answer. What is the best way to have two versions of emacs on OS X with homebrew? I need to be able to quickly switch between emacs 24 and 25 in order to properly test some packages I maintain, but it seems that switching between the two forces a full rebuild of emacs.

I figure I must be doing something wrong. So, what's the proper way to have two versions that I can quickly switch between? Is there some homebrew incantation that lets me unlink/link versions that are already built?


texts:
I am writing a custom function which is supposed to write selected text to some arbitrary file on the system. It does something like

(defun write-region-to-file (&optional arg)
  (interactive "*p")
  (write-region (point) (mark-marker) "/path/to/file/other/then/visited"))

If I then run it in a read-only buffer I get

command-execute: Buffer is read-only: #<buffer ...>

Why is this happening? I don't do any modification to the visited one, I am writing to a completely different file.

Any ideas?


texts: I'm new to the org-mode in Emacs and I can't seem to find anything on how to sort a list of todos while editing in org-mode. I know that they can be sorted through some view (e.g. agenda), but I'd really like it to sort based on due date while listing them in the file. How do I accomplish this?


texts: How to print a stack trace into the stderr from elisp?

texts:
There are cases Emacs wont print stack traces on error

How can I make elisp print a stack trace from my own code? (into the stdout/stderr for example)

Something like Python's traceback:

import traceback
traceback.print_exc()


texts: Code formatting in org-mode headlines on export to PDF

texts:
You can use formatting in headlines in org-mode. For example:

* Behavior of the _insert_ operation

This exports to PDF just fine.

If, however, your formatting is code formatting

* Behavior of the ~insert~ operation

, exporting it PDF results in an error message instead of a PDF:

org-latex-compile: PDF file built_files_ignored_by_git_tex/a.pdf wasn't produced: [undefined control sequence] Runaway argument

Within Emacs, the formatting is displayed correctly.

Is this a bug? Is there something a user can do to make the PDF build correctly?

I use GNU Emacs 24.5.1 and (according to what's written to the pdfcreator tag in the exported LaTeX document) org-mode 8.2.10.


texts: How to handle multiple kinds of errors with condition-case?

texts:
With condition-case, is there a way to handle multiple kinds of errors?

Currently I have user-error and error both being handled.

Is there a way to de-duplicate these checks to handle any kind of error?

(condition-case err
  (some-code)
  (user-error (message "%s" (error-message-string err)))
  (error (message "%s" (error-message-string err))))


texts:
My current config looks like this:

(use-package general
    :ensure t
    :config (general-define-key
    :states '(normal visual insert emacs)
    :prefix "SPC"
    :non-normal-prefix "C-SPC"

    ;; Buffer.
    "b k" '(kill-this-buffer :which-key "Kill Buffer")
))

But when I press SPC it shows +prefix next to b instead of an actual name. How can I set a name there with :which-key?


texts:
My openwith-associations includes:
("\\.xlsx\\'" "Microsoft Excel"
  (file)))

But this doesn't work. How should this association be written? Is there a better way to open the file link at point than using openwith?


texts: Copying Text from Terminal Emacs over SSH?

texts:
I have emacs running on machine A. I then connect to emacs via a terminal (over SSH) from machine B.

Question: From Machine B, how do I copy text to Machine B's clipboard to paste it, i.e., into a browser?


texts: agenda weekend and holidays red font face in org mode

texts:
I'm trying to show weekend days in agenda org-mode in red font-face
Followed this instructions to no avail

https://julien.danjou.info/org-mode-and-holidays/

Testing the link above the mentioned variables seems that don't exist anymore

[no match]

Tried this function here too. But no success so far:

color specific days in different background in org agenda

Would be awesome if holidays are in red too

any hint will be much appreciated.