texts:
Is it possible to add an "if" clause to a s-format string? The code below is adapted from bibtex-completion-apa-format-reference in the helm-bibtex package.
(s-format
               "${author} (${date}). ${title}. In ${editor} (Eds.), ${booktitle} (pp. ${pages}). ${address}: ${publisher}."
               'bibtex-completion-apa-get-value entry)

I would like to add the biblatex field ${origdate} like so if it exists.
(s-format
               "${author} (${date}[${origdate}]). ${title}. In ${editor} (Eds.), ${booktitle} (pp. ${pages}). ${address}: ${publisher}."
               'bibtex-completion-apa-get-value entry)

The above code produces this when origdate is empty:

author (2020[]). Title. In ...

I would like s-format to use (${date}) when origdate is empty and (${date}[${origdate}]) when origdate is present.
I can certainly nest the two sets of s-format code above under an if function to produce the desired results:
(if (origdate-is-empty)
    (s-format
     "${author} (${date}). ${title}. In ${editor} (Eds.), ${booktitle} (pp. ${pages}). ${address}: ${publisher}."
     'bibtex-completion-apa-get-value entry)
  (s-format
   "${author} (${date}[${origdate}]). ${title}. In ${editor} (Eds.), ${booktitle} (pp. ${pages}). ${address}: ${publisher}."
   'bibtex-completion-apa-get-value entry))

Just like to know whether there is a more concise way of doing this.


texts: What is causing the letter to the right of my point to flicker?

texts: I occasionally have the problem that the character to the right of my point starts blinking. Can anyone think of anything that could be causing this problem?


texts: Determine if an org heading has children

texts: In elisp, how can I tell whether the org heading under point is a leaf node or whether it has child headings? I've found org-list-has-child-p, but I'm having trouble delivering the struct to the function.


texts: Change the status of task from todo to done after clocking out

texts:
After org-clock-out the current todos, I have to manually change its status from todo to done.

How could automate the process.

If a clocking task was clocked-out, it's status would be changed to done automatically.


texts: activate prettier-js-mode after every save

texts:
I am using prettier-js-mode which is great and here is my configuration:

(use-package prettier-js
  :commands (prettier-js-mode prettier)
  :init (add-hook 'js2-mode-hook 'prettier-js-mode)
  :bind (:map js2-mode-map ("M-q" . prettier))
  :config
  (setq prettier-target-mode "js2-mode")
  (setq prettier-js-args '(
    "--trailing-comma" "all"
    "--bracket-spacing" "false")))

At the moment I have to M-x and select prettier-js from the meta menu.

How could I run prettier-js after a save happens?


texts: What is missing to show the desktop-dirname in the frame title?

texts:
I tried to get the value of desktop-dirname into the title of a frame:

(setq frame-title-format '("%b Desktop: "
                           (car (last (split-string desktop-dirname "/" t)))))

The (car ...) part evaluates just fine to "Something", but I don't
see it in the frame title. I see only "buffer.el Desktop:" and I don't
understand why. What's missing?


texts: Is evil-mode compatible with the `python-mode.el`?

texts:
Evil-mode has some minor wrinkles and unexpected effects when used with a few other major and minor modes, including org-mode.

Does Evil-mode, in Emacs 24.5, interfere with or reduce the functionality of python-mode.el?


texts: How to file bug report about frozen emacs

texts:
Here what I have

MacOS
Emacs started with $(which emacs) --daemon
using emacs mostly in terminal with alias emacs='emacsclient -nw'
and then emacs ~/foo.txt to edit files

So right now my emacs client is stuck.
The daemon is acting funny too. So I won't try to connect new emacsclients to this messed up daemon.

So I can't get back in to a working emacs session

How do you send the emacs devs useful info to help debug what happened.


texts: I use drawers extensively. As a result, They tend to get long.I would like a mechanism to fold them like headlines. I found outline-show-all command which makes drawers visible. I would like a global, headline specific and headline recursive mechanisms for toggling the visibility of drawers.


texts: org - keyboard shortcut to promote text to heading

texts:
How to promote a text line to a heading in org-mode?

ie: I start writing text and only later wants to structure it:

here's a start typing some text.
and continue on a 2nd line
and even a 3rd line.
but here I already start typing my 2nd paragraph
a new line of text

After exiting insert mode, now I would like to promote the 1st and 4th lines into heading like:

* here's a start typing some text.
    and continue on a 2nd line
    and even a 3rd line.
* but here I already start typing my 2nd paragraph
    a new line of text

thank you


texts: Symbol's function definition is void: use-package

texts:
I am unable to get the darcula theme working.

I have a tried moving (package-initialize) and (require 'package) but I am unable to get it working.

Here is my init.el file.

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

;; hide toolbar
;;
;; https://www.emacswiki.org/emacs/ToolBar#toc1
(tool-bar-mode -1)

;; hide scrollbar
;;
;; https://www.emacswiki.org/emacs/ScrollBar
(scroll-bar-mode -1)

;; hide menubar
;;
;; https://www.emacswiki.org/emacs/MenuBar
(menu-bar-mode -1)

;; hide splash screen
;;
;; http://stackoverflow.com/a/744681/3034693
(setq inhibit-startup-screen t)

;; hide scratch message
;;
;; https://stackoverflow.com/questions/1498258/how-do-i-change-the-scratch-message-in-emacs
(setq initial-scratch-message nil)

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

(custom-set-variables
 ;; maximize frame on start
 ;;
 ;; https://www.emacswiki.org/emacs/FullScreen#toc2
 '(default-frame-alist (quote ((fullscreen . maximized))))
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages (quote (darcula-theme))))

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

;; Darcula - Emacs theme inspired by IntelliJ's Darcula.
;;
;; https://gitlab.com/fommil/emacs-darcula-theme
(use-package darcula-theme
  :ensure t
  :config
  ;; your preferred main font face here
  (set-frame-font "Source Code Pro-10"))


texts: Restore Spacemacs project windows layouts

texts:
Opening a project I would like the windows restored as I left them. E.g.
tests.py on the left and a terminal /home/projectdir/>$ on the right:

|-----------+-----------|
| tests.py  | >$_       |
|           |           |
|-----------+-----------|

However, after restarting emacs, followed by Spc p l [Helm switch project
layout] and selecting the project, none of my set Window is restored but all
I'm asked is to open a file from the projectfolder. Furthermore I see the layout's (project) name in the modeline.


texts: How to sync the read history of Gnus between computers through Dropbox?

texts:
I try to read email and mail list with Gnus on different computer. I am able to sync the configure files through Dropbox and it works fine.

But I don't know how to sync the read history. I am always get the read articles show as unread on different computers repeatedly.


texts:
In order to use ssh agent forwarding with emacs in daemon mode, running on a remote server, I've come-up with the following.

I have an alias for the client like so:

alias emacsclient="update_agent;/usr/local/bin/emacsclient -nw"

Which is calling the following which will update a soft-link to the current agent socket each time the emacs client is started (it is not used in any other circumstance):

alias update_agent='if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then ln -sfv "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock; fi'

Providing I don't run 2 emacs clients simultaneously, and then kill the 2nd client before the 1st, this works fine.

In order to make the daemon use the updated socket I must set SSH_AUTH_SOCK to the soft link at daemon creation time.

I came up with 2 ways of doing this.

This way works:

 alias emacs="SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock /usr/local/bin/emacs --daemon"

This way does not work:

alias emacs="/usr/local/bin/emacs --daemon --eval '(setenv \"SSH_AUTH_SOCK\" \"~/.ssh/ssh_auth_sock\")'"

Both return the same value when getenv is called on SSH_AUTH_SOCK from within an emacs client.

But any attempt to use Dired on a remote directory eg C-x d /ssh:servername: or to ssh from M-x shell returns the following using the 2nd alias:

Failing with `Permission denied (publickey).`

My question is why doesn't the 2nd alias for emacs daemon allow ssh agent to be used for authentication?

Note - the use of the soft-link is necessary to make sure that not only the emacs daemon environment is updated, but all spawned M-x shells within the daemon are also updated.  Otherwise it would be a trivial case of just updatng the daemon's SSH_AUTH_SOCK environment variable each time you connect to the daemon with setenv to the value of the current terminal's socket?
Although if anyone has a better/different way of using ssh agent forwarding with emacs daemon, then I'm keen to hear it too!

References:

https://superuser.com/questions/180148/how-do-you-get-screen-to-automatically-connect-to-the-current-ssh-agent-when-re/424588#424588

https://chrisdown.name/2013/08/02/fixing-stale-ssh-sockets-in-tmux.html

http://ergoemacs.org/emacs/emacs_env_var_paths.html


texts: Hide region from syntax highlighting and indentation

texts: c++-mode does not handle the C++17 R"delim()delim" string literals. Is there a way to mark a region (via comments?) so it will not be syntax highlighted and will not confuse the indenter?


texts:
After upgrading emacs from 24.4 to 26.3 on Windows, everything works fine except for one thing: the list-packages window has become horribly slow. Like, the cursor moves one second after the keystroke.

I have upgraded all packages (despite the sluggishness of the interface) and also tried (byte-recompile-directory "~/.emacs.d/elpa" 0 t) but the situation has not improved.

Any idea?

These are the profiler's results (entered list-packages and moved the cursor around a bit):

- command-execute                                                 140  71%
 - call-interactively                                             140  71%
  - funcall-interactively                                          94  47%
   - execute-extended-command                                      47  23%
    - sit-for                                                      46  23%
       redisplay                                                   45  22%
    - command-execute                                               1   0%
     - call-interactively                                           1   0%
      - funcall-interactively                                       1   0%
       - profiler-report                                            1   0%
        - profiler-report-cpu                                       1   0%
           profiler-cpu-profile                                     1   0%
   - next-line                                                     47  23%
    - line-move                                                    47  23%
       line-move-visual                                            46  23%
  - byte-code                                                      46  23%
   - read-extended-command                                         46  23%
    - completing-read                                              46  23%
     - completing-read-default                                     46  23%
        read-from-minibuffer                                       46  23%
+ ...                                                              57  28%

...after a bit of bisecting my .emacs, I've found that the offending line is this one:

(set-face-attribute 'default nil :height 120 :family "Inconsolata" :foundry "outline"))

if I remove this, list-packages is back to normal. But why? Also, I like Inconsolata :-)

Meanwhile I've also discovered that org-mode becomes very slow if unicode symbols are visible (but not if they are hidden inside a collapsed headline); I suspect this is related.


texts: Is there any way to get the memory size (usage) of a Lisp variable/value?

texts:
Basically sizeof for lists, hashmaps, etc., with nested structures.
I could of course disable garbage collection and then compare numbers from memory usage functions before and after allocation, getting vaguely informative but imprecise numbers—due to probably also having created intermediate vars.
But maybe there's a method that involves less approximate guesswork and more straightforward calculation?


texts: Incorrect pixel count returned on retina display

texts:
I am running Emacs 26.3 on a 15" MacBook Pro with Retina display. While Emacs renders razor sharp on my screen, it does not seem to be aware of my correct pixel count. E.g.,

#+BEGIN_SRC emacs-lisp

(concat
 (number-to-string (x-display-pixel-width))
 " x "
 (number-to-string(x-display-pixel-height)))

#+END_SRC

Returns a value of 1440 x 900. But if I run the following,

#+BEGIN_SRC sh

system_profiler SPDisplaysDataType |grep Resolution

#+END_SRC

I get 2880 x 1880.

Is this a known bug? Or is there some variable I can customize to make my system retina-aware?


texts: How can I find out which TeX engine my AUCTeX uses? How can I change the TeX engine my AUCTeX uses (specifically, (a) to LuaTeX, (b) to XeTeX)? Following this post, I tried to inspect the value of the variable TeX-engine, however this variable isn't defined in my environment, even though AUCTeX works fine.


texts: how to - org file with file level properties automatically added

texts:
I have several file level properties (like #+OPTIONS: toc:nil
) always defined at begin of all my org files. I wonder whether it is possible to make a org template so that all org files I create in emacs will have these properties added automatically?


texts: Package that links words as they are typed to existing org-files/-headers?

texts:
A silly question.

I try to link my org-files more closely together. I looked into org-roam and org-brain but i'm not convinced that these packages provide what i have in mind (haven't tested it).

As an example what i mean. When i write following sentence in org-mode:

I go to school every monday.

That as soon as i hit SPC after the word school that school is linked to the file school.org or org-header * School. Of course it would search in a default directory or so.

Is there a package providing such functionality in org-mode?


texts: Indentation with uniform initialization spanning several lines

texts:
This is how the following line is currently indented for me:
std::array<int, 4> arr { 54, 37,
    54, 37 };

However, I would like it to be indented like this:
std::array<int, 4> arr { 54, 37,
                         54, 37 };

I think I need to modify the brace-list-entry variable in C Offsets Alist, but I don't know to which value. I can fix the above example by manually setting it to 21 characters, like this:
(c-set-offset 'brace-list-entry 21)

but I need a general solution.
How to align the continuation lines of uniform initialization with the first element following the opening brace? The reason I ask is because this is what clang-format expects and there seems to be no way to change that.


texts: UTF-8 error everytime Org-gcal sync entries

texts:
I continue to get bogged down with this error every time I sync from gcal, I have this ut8 flag set in my config as well, any direction would be helpful.

(prefer-coding-system 'utf-8-unix)


texts: Why does server-eval-at seem to change the behavior of read-string?

texts:
I am trying to create a script that, when run with emacs, will read commands from stdin a line at a time, execute them in another emacs process (with server-eval-at) and print the result. The process should exit when no more input is available. I have come up with a basic protocol and everything seems to work when using eval locally, but after introducing server-eval-at the emacs process hangs instead of exiting at the end of input.
For initial development I was doing the evaluation inline, in the same process that was reading the input. That seems to work well. That script looks like
(while (setq command (ignore-errors (read-string "")))
  (setq command (read command))
  (message "[DEBUG] Received command %s" command)
  (let ((result (eval command)))
    (message "[DEBUG] Response received %s" result)))

In a shell script, for easier testing:
#!/bin/sh
cd "$(mktemp -d)"
cat <<EOF > script.el
(while (setq command (ignore-errors (read-string "")))
  (setq command (read command))
  (message "[DEBUG] Received command %s" command)
  (let ((result (eval command)))
    (message "[DEBUG] Response received %s" result)))
EOF

echo '(message "hello world")' | \
emacs --quick --batch --script "$PWD/script.el"

An example of running this, with output:
$ ./t2
[DEBUG] Received command (message hello world)
hello world
[DEBUG] Response received hello world
$

As you can see, the debug messages are printed. The process exits at the end of input.
All of this is expected and OK.
Now I want to run the incoming commands on the server, so I use server-eval-at. Here is that script
(require 'server)
(while (setq command (ignore-errors (read-string "")))
  (setq command (read command))
  (message "[DEBUG] Received command %s" command)
  (let ((result (server-eval-at (getenv "RPC_SERVER_NAME") command)))
    (message "[DEBUG] Response received %s" result)))

Another shell script, for easier testing
#!/bin/sh
cd "$(mktemp -d)"

export RPC_SERVER_NAME="$PWD/emacs"
emacs --quick "--fg-daemon=$RPC_SERVER_NAME" >stdout.log 2>stderr.log &
sleep 1

cat <<EOF > script.el
(require 'server)
(while (setq command (ignore-errors (read-string "")))
  (setq command (read command))
  (message "[DEBUG] Received command %s" command)
  (let ((result (server-eval-at (getenv "RPC_SERVER_NAME") command)))
    (message "[DEBUG] Response received %s" result)))
EOF

echo '(message "hello world")' | \
emacs --quick --batch --script "$PWD/script.el"

An example of running this, with output:
$ ./t1
[DEBUG] Received command (message hello world)
[DEBUG] Response received hello world

The output looks fine, but the process does not exit!
I have introspected these processes a few ways:

top shows that the server-eval-at emacs (client) is consuming 100% CPU.
strace shows that the server-eval-at emacs (client) is calling read on stdin (fd 0) repeatedly, and receiving an empty string each time
strace shows that the eval emacs calls read on stdin twice: once to read the command, and once receiving an empty string before exiting.
gdb on the server-eval-at emacs (client) has a Lisp Backtrace with read-string at the top.

I inlined server-eval-at and was able to identify that calling accept-process-output
is necessary for the subsequent call to read-string (in the next loop iteration) to behave differently, but it is hard for me to
dig much deeper than that.
I tried these same steps against emacs 26.3 and observed the same result.
I am using emacs 27.1 on Ubuntu Linux 18.04, as installed with evm.


texts: Specify and use inferior shell only once

texts:
I know you can customize settings or set environmental variables to get emacs to use other shells in shell-mode (1, 2). Is it possible to simply start a shell specifying which shell you want to use interactively?

Like: M-x other-shell RET /path/to/csh RET

Or set up something in your init file to let you use other shells fairly easily without changing the default?


texts: Why does this code fail to nullify all keybindings in a keymap?

texts:
Long story short, there's a little library I like but I don't like any of the default keybindings.  E.g. it's a global minor mode and binds a function to C-c C-s, but that shadows org-schedule in my org and org-agenda buffers.

I want to keep the little library but get rid of all the bindings in the little library keymap.

In an early attempt to do this, I tried the following (after confirming that little-library-mode-map is where the bindings live):

(with-eval-after-load "little-library-mode"
  (setq little-library-mode-map (make-sparse-keymap)))

The code "succeeds" (C-h v little-library-mode-map RET shows that it's just (keymap) now) but all the little library keybindings still "work" (C-c C-s still does the little library function, including in org and org-agenda buffers).

I've found another way to solve my issue, but I'm really curious why this approach fails.  Emacs' keybindings still seem like black magic to me.


texts: Elisp regex matching - evaluate as region vs as individual sexp gives different answers

texts:
Here's a chunk of code:

(defvar test-string "bla bla bla 10.10.10.10 bla bla bla")

(string-match "[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+" test-string)
(message (match-string 0 test-string))

When I select the entire block it's evaluated correctly (using eval-region):

10.10.10.10

When I evaluate sequentially (using eval-last-sexp) I get the following:

bla bla bla 10.1

I've looked at the docs of the respective functions but couldn't find any help.

My Emacs version is GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, Carbon Version 157 AppKit 1347.57).


texts:
Using emacs 25.2.2 on Kubuntu 18.04.

Using list-packages I installed evil. Using customize-variable I added (evil-mode t) in my ~/.emacs.d/init.el file.

But still when I restart emacs, there is no trace of evil mode! list-packages shows evil as an installed package. But there are no evil commands available with M-x and evil-mode is not enabled anywhere.

What is going on here? How do I set things right?


texts: How to control cursor position when using a function for inserting a skeleton

texts:
I am using the following function to make a new text file containing premade rows.  The text file is named with a date and time tag, and stored in a /notes/ folder.

(defun myfun-create-file-with-rows()
  (interactive)
  (find-file (format-time-string "C:/Users/myUser/notes/%Y-%m-%d--%H-%M-%S.txt"))
  (insert "My title\n\n\n\n\n\nLinks:\n")
  )

The function inserts the row "My title" followed by 5 blank rows and the row "Links:".

When I use this function the position of the cursor (point) ends at the bottom of the inserted lines, below the row "Links:". How can I make the cursor end a line below the row "My title" ?


texts: How to get colored syntax highlighting of code blocks in asynchronous Org-mode exports to HTML?

texts:
Colored syntax highlighting of code blocks in .org files works well when executed through the main init.el file. However, when setting up Emacs and Org-mode to publish projects asynchronously, colored synatax highlighting is not present and only bold and underlined formatting is used.

I have the following minimal example:

init.el

(add-to-list 'load-path "~/.emacs.d/modes/org-mode-8.2.10/lisp")
(add-to-list 'load-path "~/.emacs.d/modes/htmlize-1.6.1/")
(require 'org)
(require 'htmlize)

(setq org-src-fontify-natively t)

(setq org-publish-project-alist
      '(
        ("prj"
         :base-directory "~/tmp/org-export-test/"
         :base-extension "org"
         :publishing-directory "~/tmp/org-export-pub/"
         :recursive t
         :publishing-function org-html-publish-to-html
         )))

;; async export options
(setq org-export-async-debug t)
(setq org-export-async-init-file
      (expand-file-name "export-async-init-file.el"
            (file-name-directory user-init-file)))

(global-set-key (kbd "C-c C-8")
                (lambda () (interactive) (org-publish "prj")))
;;      (lambda () (interactive) (org-publish "prj" :ASYNC t)))

export-async-init-file.el

(add-to-list 'load-path "~/.emacs.d/modes/org-mode-8.2.10/lisp")
(add-to-list 'load-path "~/.emacs.d/modes/htmlize-1.6.1/")
(require 'org)
(require 'htmlize)

(setq org-src-fontify-natively t)

(setq org-export-async-debug t)

Org file in the project folder

Hello world example code:

#+BEGIN_SRC python
def hello_world(name):
    print(name)
#+END_SRC

The above should be colored and highlighted.

In the above settings I get

When switching on the asynchronous export however (switching the comment on the last two lines of init.el), I get

How can I set up the above configuration to get color highlighting in asynchronous export as well?

(Note: While I would like to make colored syntax highlighting work in Org-mode 8.2.10, I have also tried the above example with the latest Org-mode 9.0.5 and have found the same behavior.)


texts:
I just upgraded emacs to 25.3. Before the upgrade when I opened a Python shell, it would ask me whether I wanted a 'dedicated' shell (for the buffer I was in), to which I usually replied 'yes'. Now, I do not have the option. I want a dedicated process (the opposite of this question).

I searched the Python options, and didn't see anything that looked promising. Does the 'flying circus' python mode have support for multiple python shells? If not, does anyone know where I can find a version of python mode that works with Emacs 25, and has this functionality?


texts: How to take line from recent commit with Magit

texts:
Use Magit to view the log with show diffs (-p).
Inspect 4 commit old commit.
Navigate to a few lines I've since deleted, but want back my project.

I can mark the lines but cannot copy them, which would be a sufficient solution for me. But, since we're opening the discussion, is there a better way to do this using Magit?


texts: Unable to load color "color-235" when using `gruvbox` theme

texts:
I have the following line in my .emacs to load the gruvbox theme:

(load-theme 'gruvbox t)

When opening Emacs, I get the following error

Unable to load color "color-235"

However, when I call load-theme again, everything works out fine.

Why is this error occurring?

How can I fix this so that I do not need to call load-theme every time I open Emacs?


texts:
I'd like to send some commands to the terminal Emacs is running in, using send-string-to-terminal. However, some terminals don't support the command I have in mind.

When this is the case, the command is echoed after the cursor, temporarily overwriting the display, and causing graphical corruption:

Result of running M-:(send-string-to-terminal "\e[5 q") in xfce4-terminal

(Note that the text appears in the echo area by mere coincidence—if I had run the code using a keybinding in a different buffer, the output would be positioned after the cursor)

Obviously, this is not desirable. Is there a way to hide the output (or mask it by redrawing the display in that region) so the command can silently fail?


texts:
i am keen on using jira with org-mode . org-jira-mode looks like a potential candidate but i use HTTP REST in most scenarios, and i don't want to break my head with soap protocol for the sake of org-jira-mode.

Is there any other jira plugin that does its talk through the  rest protocol?


texts: How do I make markdown or org mode hide formatting characters until I edit?

texts:
I'd like to hide markdown / org-mode markup characters when viewing a file, so I set org-hide-emphasis-markers and markdown-hide-markup to t. However, when editing a section of text, I'd like to see the characters. A function like markdown-toggle-markup-hiding will change the setting for the entire buffer.

Is there an easy way to apply the hiding to the entire buffer except the current line (or paragraph)? That way most of the buffer will be in "view" mode but when I move the cursor to edit something, that line will let me see the formatting characters.


texts: Collaborative editing:Using Rudel to connect to a Gobby process

texts:
I would like to set a server to host a Gobby process https://gobby.github.io/.
It would host latex files for example

And I was thinking of using rudel https://www.emacswiki.org/emacs/Rudel to connect to the server and compile the tex file locally.

The Gobby process allows for multiple users to edit a file at the same time.

The rudel package seem to have been abandoned no new recent update.

I have been able to connect two rudel sessions for collaborative editing but this session is not secure on the one that use the Gobby process is.
Yet could not use rudel to connect to the gobby process. The function join-session seem to get stuck on “Joining (new)”.

Have anyone tried and succedded to connect rudel to a Gobby process? Any help is welcome.


texts:
I've been using emacs for 3 months and I never have problem like this, I installed a theme then my emacs had lag. Actually it is not a big deal there is small diffrence between without theme and with theme but I wanted to know why is this happening.

https://github.com/emacsfodder/emacs-clues-theme

This is the theme which I said above.

If you think it is not about theme here is my init file(currently I'm kind of newbie) :

; load theme
(load-theme 'ritchie t)
(add-to-list 'load-path "~/.emacs.d/")
; for dirtree package
(require 'dirtree)
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(yas-global-mode 1)
; care about this place
;(define-key yas-minor-mode-map (kbd "<tab>") nil)
;(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
; care about this place
(setq ac-source-yasnippet nil)

(semantic-mode 1)
(defun my:add-semantic-to-autocomplete()
  (add-to-list 'ac-sources 'ac-source-semantic)
)
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
(add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete-1.3.1/dict")
(global-auto-complete-mode t) ; section1
;(ac-set-trigger-key "TAB")
;(ac-set-trigger-key "<tab>")

(defun my:ac-c-headers-init ()
  (require 'auto-complete-c-headers)
  (add-to-list 'ac-sources 'ac-source-c-headers))

(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)

(add-to-list 'load-path "~/.emacs.d/ajc-java-complete/")
(require 'ajc-java-complete-config)
(add-hook 'java-mode-hook 'ajc-java-complete-mode)
(add-hook 'find-file-hook 'ajc-4-jsp-find-file-hook)
(setq ajc-tag-file-list (list (expand-file-name "~/.java_base.tag")))
(setq ajc-use-plain-method-completion t)

(add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp")
(add-hook 'java-mode-hook 'load "jde")
;(load "jde")

(add-to-list 'load-path "~/.emacs.d")
(require 'linum)
(global-linum-mode 1)

(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(yas-global-mode 1)
; care about this place
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
; care about this place
(setq ac-source-yasnippet nil)

;(add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")
;(require 'auto-complete-config)
;(ac-config-default)
;(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
;(global-auto-complete-mode t) ; section1
;(ac-set-trigger-key "TAB")
;(ac-set-trigger-key "<tab>")

;(defun my:ac-c-headers-init ()
 ; (require 'auto-complete-c-headers)
  ;(add-to-list 'ac-sources 'ac-source-c-headers))

;(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
;(add-hook 'c-mode-hook 'my:ac-c-headers-init)

(add-to-list 'load-path "~/.emacs.d/iedit")
(require 'iedit)
(define-key global-map (kbd "C-c ;") 'iedit-mode)

;(semantic-mode 1)
;(defun my:add-semantic-to-autocomplete()
 ; (add-to-list 'ac-sources 'ac-source-semantic)
;)
;(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq indent-line-function 'insert-tab)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Ubuntu Mono" :foundry "unknown" :slant normal :weight normal :height 113 :width normal)))))


texts: How to let AUCTeX open PDF with pdf-tools

texts:
Some TeX/LaTeX editor has support for embedding PDF viewer, and forward/backward search support.

I want to configure AUCTeX and pdf-tools to this result.

I found a discussion in mailing list.

https://lists.gnu.org/archive/html/auctex/2015-02/msg00013.html

It give out a method to implement this opening PDF file with pdf-tools in Emacs.
I followed that, but it does not work.

Here is my config:

(require 'tex-site)
(require 'latex)

;;; AUCTeX config
(setq TeX-auto-save t
      TeX-parse-self t)

(setq-default TeX-master nil)

;; automatic detection of master file
(defun guess-TeX-master (filename)
  "Guess the master file for FILENAME from currently open .tex files."
  (let ((candidate nil)
        (filename (file-name-nondirectory filename)))
    (save-excursion
      (dolist (buffer (buffer-list))
        (with-current-buffer buffer
          (let ((name (buffer-name))
                (file buffer-file-name))
            (if (and file (string-match "\\.tex$" file))
                (progn
                  (goto-char (point-min))
                  (if (re-search-forward (concat "\\\\input{" filename "}") nil t)
                      (setq candidate file))
                  (if (re-search-forward (concat "\\\\include{" (file-name-sans-extension filename) "}") nil t)
                      (setq candidate file))))))))
    (if candidate
        (message "TeX master document: %s" (file-name-nondirectory candidate)))
    candidate))

(add-hook 'LaTeX-mode-hook
          '(lambda ()
             (setq TeX-master (guess-TeX-master (buffer-file-name)))
             ))

;; enable RefTeX in AUCTeX (LaTeX-mode)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode

;; view generated PDF with `pdf-tools'.
(unless (assoc "PDF Tools" TeX-view-program-list-builtin)
  (add-to-list 'TeX-view-program-list-builtin
               '("PDF Tools" TeX-pdf-tools-sync-view)))
(add-to-list 'TeX-view-program-selection
             '(output-pdf "PDF Tools"))

;; LaTeX source code block syntax highlighting.
;; [ minted ]
;; toggle shell escape using [C-c C-t x].
(defun TeX-toggle-escape ()
  "Toggle Shell Escape"
  (interactive)
  (setq-local LaTeX-command
              (if (string= LaTeX-command "latex") "latex -shell-escape"
                "latex"))
  (message (concat "shell escape "
                   (if (string= LaTeX-command "latex -shell-escape")
                       "enabled"
                     "disabled"))
           ))
(add-hook 'LaTeX-mode-hook
          '(lambda ()
             (local-set-key (kbd "C-c C-t x") 'TeX-toggle-escape)))


texts: What is the difference/purpose between "require" and "package-install"?

texts:
I am trying to understand the subtle nuances of Emacs' packaging system(s). I do not find that anyone has really clarified or explained the difference between two, what I assume to be, key components of Emacs package system: require and package-install.
I commonly see code like the following in many init.el files (illustrative example):
(require 'package) ; Use Emacs package system
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) ; Add MELPA package repository as a place to go lookup for packages
(package-initialize) ; Turns Emacs package system on
; ... refresh code omitted for brevity
(unless (package-installed-p 'helm) ; Only installed "helm" if we don't see it as already installed
    (package-install 'helm)
)

(require 'helm) ; Get helm to actually use
; ...

The thought process for understanding what is going on:

require seems to be called for package but the "package" for package does not need to be "installed". Is this internal somehow?
Is package needed for use-package to work but not require, correct?
For helm (in this example) we must do/use package-install (with some checks) to first "install" helm and then require to actually use it. Is this correct?
If we did (use-package helm ... ) then we would not need either require or package-install 'helm, right?

To extrapolate:
If one wanted to use any particular package, they first need to make sure they have an equivalent package-install call / statement prior to invoking require (or just utilize a use-package which will "merge" both steps) on that particular package, correct?
I just want to be sure I am properly setting up my usage of packages and so forth. Emacs is very confusing when it comes to packages, installing, requiring, etc. ... at least that I find.

Q/A Housekeeping Notes:
According to common advice, there are important differences in the Emacs major versions, so I would like an explanation for each (Emacs version 25, 26, and 27, respectively) for others who may come across the same question but on an older version (if it matters).
I am currently on Emacs 27.2 on macOS Catalina (just to be clear).
In an attempt to preempt "duplicate of ..." or "searching will find ...": In my searching, I found require vs. package-initialize? but it does not look like anyone really answered the question to satisfaction (or clearly).


texts: Is there a way to make emacs adhere to fdo spec?

texts:
There's freedesktop.org spec for config placement.
Most of the software adheres to it placing config files into ~/.config, cache files into ~/.cache etc. This greatly simplifies backups, config management etc. One of the few unfortunate exceptions is Emacs. Is there a way to force it to behave properly?


texts:
(error "You must be before a list form")

I instrument a function in emacs. Now, this function is calling some other function. I try to step into this new function using the shortcut key i (step-into-function). Emacs throws an error, with this message -

You must be before a list form

The irony is, for forms emacs evaluate, it always places the cursor at the end of a form like this,

So, why doesn't edebug step-in work properly?

Since my cursor keeps blinking, i have put a black mark for cursor instead of the usual white mark.


texts: make org-agenda-mode always have (org-agenda-follow-mode) toggled on

texts: I want to make it so that org-agenda-mode defaults to always having (org-agenda-follow-mode) toggled on.


texts: Resize windows line by line, not pixel by pixel

texts:
Is it possible enforce that Emacs changes the window size line by line, not by some count of pixels, to eliminate the situation when I see a half-line on the screen?

I mean window in Emacs sense (commands like C-x }, C-x ^ do it). Funny, but frame resizing does it in line-by-line manner. I use the macOS Cocoa version.

(Currently I can just drag separator by mouse and put it in-the-middle of the line height).


texts:
After building a two column, 3 window layout with one tall column and two stacked equal sized shorter columns next to it, when I run commands like magit or ag that bring up a new buffer, often one of the shorter windows is resized so that it almost fills that column, and this leaves the other shorter window with just a hand full of lines left.

How can I always prevent emacs from resizing my windows after I've set them up? I've heard of winner mode, but it's less than ideal because 1) undoing the resize has the unfortunate side effect of also obscuring the buffer that I wanted to work with in the first place that triggered the resizing (ag or magit in my case), and 2) I would prefer emacs not to automatically resize frames in the first place.

Is there some configuration options that I can use to prevent emacs from ever resizing any of my windows, no matter what buffers it's trying to display?l


texts: export TODO / DONE with different font face

texts:
When I export TODO / DONE to pdf, it gets exported as large, bold font.
I would like to export using regular font. (10 pts). Is it possible ?
Kindly help.


texts: Syntax highlighting fails on clone-indirect-buffer-other-window

texts:
I normally use indirect buffers while I edit python code in python-mode, I create them by running clone-indirect-buffer-other-window. While the syntax highlighting of the main buffer looks just fine, sometimes it is wrong in the indirect one. Specifically, it seems like some closing quotes are ignored adn so big chunks of my code are coloured as if they were part of long literal string.

I have not found references of this elsewhere, and have not clue why it could be happening. Does anybody know why this is and/or how to solve it?

This question could be related, be he does not mention indirect buffers (I only have this problem with those), and also my indirect buffer do not refresh to proper syntax highlighting even if a wait several minutes.


texts: org-mode in-buffer todo setting not working as expected

texts:
I am using org-mode TODO tracking change (in-buffer settings) and I'm having some issues. All the info is taken from the official docs (https://orgmode.org/manual/Tracking-TODO-state-changes.html)

I have added the buffer setting line at the top:

#+TODO: TODO(t) BUG(b) WAIT(w@/!)| DONE(d@/!) CANCELLED(c@/!)

and it's working, except two features I would like to have:

When changing to the WAIT state, it won't ask me for a note and the timestamp is not recorded either.
The DONE state is not grayed out as it's the case with CANCELED, despite both being specified after the "|" pipeline character.

I have not tested the same setting in a global init.el config because I need this setting different for each file.


texts:
I have org-mode file with more than 10k lines of notes and traversing through the tree (just basic up/down movements) is very slow (to the point that it's unusable). What can i do to make it work faster?

I know i can split the big files into many smaller ones, but i want to have it encrypted (into *.org.gpg) and don't want to enter the password every time i open different file.

Thank you for help.


texts: Is it possible to group series of changes under single undo step?

texts:
I am writing template insert function for a file format that needs to keep header counter updated.

I'd like that undo operation removes not only in place template changes but also corresponding header update.

For example starting from:

## 2
# 1
- ...
# 2
- ...

function will insert the template:

## 3
# 1
- ...
# 2
- ...
# 3
- <here>

and C-/ (M-x undo) will return buffer state to original in one step.

Like rollback in SQL ))

UPDATE I do nothing in regard to my question and it works as I want:

(defun gaphrase-next-num ()
  (save-excursion
    (goto-char (point-min))
    (let (beg end num)
      (catch 'return
        (when (looking-at "## \\([1-9][0-9]*\\)")
          (setq beg (match-beginning 1)
                end (match-end 1))
          (setq num (string-to-int (buffer-substring beg end)))
          (delete-region beg end)
          (goto-char beg)
          (setq num (1+ num))
          (insert (int-to-string num))
          (throw 'return num))
        (insert "## 1\n")
        1))))

(defun gaphrase-insert-template ()
  (interactive)
  (forward-line 0)
  (when (looking-at "# ")
    (forward-line 1))
  (unless (re-search-forward "^# " (+ (point) 10240) t)
    (goto-char (point-max)))
  (forward-line 0)
  (while (memq (char-before) '(?\  ?\n ?\t))
    (delete-char -1))
  (insert "\n# ")
  (insert (int-to-string (gaphrase-next-num)))
  (insert "\n- \n")
  (backward-char))

but I like to state such behavior explicitly.

UPDATE 2 With a help of @Drew I checked elisp manual:

  The editor command loop automatically calls ‘undo-boundary’ just before executing each key sequence, so that each undo normally undoes the effects of one command.

It looks like Emacs undo all changes at once for single interactive command. Only some special commands are treated especially, like self-insert-command because it would be boring to undo each character individually. I am not sure though if it's entire true.


texts: Creating a menu from file / directory structure upon html export

texts:
I would like have a menu created from the directory structure of the org files created as a html menu that is inserted at the top of each html file.
I know I can generate a sitemap that spans multiple files, so the required parsing is done anyway, but what about a menu in each file?

Let's say I have a directory structure like this:

|- News.org
|- Stuff.org
|- Coding
   |- Emacs.org
   |- Lisp.org

I would like that all four html files that are generate have a menu that says "News - Stuff - Coding", and if coding is selected, there is a submenu that says "Emacs - Lisp".

The styling of the menus is not important here, but is it possible to produce something like this (that can then be styled via css)?


texts:
I keep some files in RST and rst-mode has C-c C-t C-t runs the command rst-toc which open all section titles in separate buffer. I can search ignoring actual document content which tends to have massive amount of searched term (so occur or isearch is a wasting of time).

Other files I keep in .org files.

Can I search / isearch only by section titles?

I'd like to keep using .org mode as I set convenient archiving of old info.


texts: How can I run a command on several buffers / files?

texts:
I'm working on some code that is spread across several files.

I keep finding myself doing whitespace-cleanup and indent-region (on the whole file), and having to do it on each of the six files.

Any way to say: 'do tidying up on all .c and .h files currently open',

or maybe use emacs in batch mode from the bash shell?


texts: Defining a simple transient with a default value

texts:
I'm trying to add a very simple transient thus:
(transient-define-prefix simple-transient ()
       "A simple transient"
       ["Arguments"
        ("-a" "Address (default 127.0.0.1)" "--addresss=")
        ("-p" "Port (default 554)" "--port=")
        ("-v" "Use verbose logging" "--verbose")
       ["Actions"
        ("r" "Run" run-command)])

All I want to do is have say "verbose" on by default, or set port to something else, but I can't fathom the docs - is there a simple way of doing this?


texts: emacsclient --eval command to bring a background emacs window to front

texts:
Suppose I already opened a emacs but its in the background. So, is there an emacsclient eval option that I can type in the shell like:

emacsclient --eval "(bring-existing-emacs-window-to-front)"

To bring the background emacs window to the front?

This can be pretty handy, since I'm always using
emacsclient -c --eval "(find-file \"afile\")". Which unfortunately opens the frame in the background instead of front.


texts: Is there a way to evaluate from top of buffer to point?

texts:
While doing statistical work in ESS, I often want to evaluate everything from the top of buffer to point. This is to make sure that my analysis is reproducible (i.e. script can be run from top to bottom and gives the right result).

Is there a way to do this in ESS?


texts: How to automatically adjust an Org task state with its children checkboxes

texts:
I have several tasks in my Org file, one of which has items starting with a checkbox (but only those). They all have a statistic cookie at their end ([n/m]).

I'm looking for a way to automatically update the parent task from TODO to DONE once all of the checkboxes are marked as done as well.

The documentation says:

  If you would like a TODO entry to automatically change to DONE when all children are done, you can use the following setup [...]

  Another possibility is the use of checkboxes to identify (a hierarchy of) a large number of subtasks (see Checkboxes).

The way I understand that last part is that if children items are checkboxes, parent state should already be automatically updated (which is not the case).

What am I missing?

Edit:

From org-after-todo-statistics-hook's documentation (org.el):

  Hook that is called after a TODO statistics cookie has been updated.
  Each function is called with two arguments: the number of not-done entries
  and the number of done entries.

Which means that the proposed code from orgmode.org:

(defun org-summary-todo (n-done n-not-done)
  "Switch entry to DONE when all subentries are done, to TODO otherwise."
  (let (org-log-done org-log-states)   ; turn off logging
    (org-todo (if (= n-not-done 0) "DONE" "TODO"))))

(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)

won't count checkbox items.


texts: Typing quickly when Control, Alt and Esc are hard to reach

texts:
I'm very new to Emacs and I'm trying the built-in tutorial. After I went through the basics, I found it really hard to reach the Ctrl and Alt or Esc keys. I'm trying to type faster but since all the commands require these keys, I'm not able to be fast at all. I have searched,  but it seems that nobody is complaining about these keys.

I already know that you can swap the Ctrl and Caps Lock keys, but I prefer not to do that because I heard that it is not recommended.

How can I make it easier to type commands?


texts: Change focus to *Help* buffer after running describe-mode

texts:
When I type C-h m for describe-mode the frame splits into two windows with the current buffer on top and the *Help* buffer below. But the focus stays in the current buffer, so I usually have to type C-x o to move focus to the *Help* buffer, and then scroll down with the page-down key to find what I am looking for.

I tried to improve this work flow by automatically give focus to the *Help* buffer:

(advice-add 'describe-mode :after 'other-window)

But now I get error:

Debugger entered--Lisp error: (wrong-type-argument stringp 1)

when I type C-h m.


texts: org-block-background font not having effect

texts:
I use variable-pitch-mode with org buffers. Normally I set org-block to fixed-pitch and the code between #+BEGIN_SRC and #+END_SRC are properly rendered as fixed width fonts, also with proper syntax highlighting. However starting from last week, for some reason, although the code block font still had proper syntax highlighting, the face became the same as the variable-pitch-face as normal org-mode texts. I update my packages periodically and I think an update in org-mode caused the issue but I'm not sure what happened.

Update:

Turns out this is actually related to org-block-background face, which has been removed in org version 8.3.1 in commit f8b42e8, thus the bug. Not sure if there's a solution yet. https://stackoverflow.com/questions/26290924/fontify-r-code-blocks-in-org-mode-8 https://lists.gnu.org/archive/html/emacs-orgmode/2015-08/msg00510.html

I'm currently just locking my org-mode version to the older one.

Update 2:

The newest org-mode release, version 9.0.0, apparently lets src-blocks inherit org-block face, while the org-block-background face becomes obsolete. So now just by setting org-block face you should be able to have fixed-width fonts for all codes.


texts: Is there a package to simplify clickable text?

texts:
I'm writing a debugger front end, and in that over the course of program execution a number of marks get added inside the source code. In other buffers such as a buffer showing execution history, or a buffer containing backtrace or callstack, I'd like to have in those buffers text information that click through to the source text.

Looking at http://www.gnu.org/software/emacs/manual/html_node/elisp/Clickable-Text.html , the process to add clickable text seems a bit cumbersome.

For example just to set a region of text to be clickable I need something like:

(setq link-start (point))
(insert (format "%s" (realgud-loc-marker loc)))
(setq link-end (point))
(add-text-properties
 link-start link-end
 '(mouse-face highlight
      help-echo "mouse-2: go to this location"))
(setq map (make-sparse-keymap))
(define-key map [mouse-2] 'realgud:follow-link)
(define-key map [mouse-1] 'realgud:follow-link)
(define-key map [follow-link] 'mouse-face)
(put-text-property link-start link-end 'keymap map)
(put-text-property link-start link-end 'loc loc)

And then I also need a definition to realgud:follow-link:

(defun realgud:follow-link(event)
  (interactive "e")
  (let* ((pos (posn-point (event-end event)))
     (loc (get-text-property pos 'loc)))
    (if (realgud-loc-p loc)
      (realgud-loc-goto loc))))

All of this seems a bit boilerplate and there's a lot of it. I could write my own routines, for this, but since this seems like a pretty basic think to do: link some text in a buffer to a mark somewhere else, I figure there must already be a package that simplifies the above. Is there?


texts:
I don't know what happened with org-babel and Python recently. My intuition and my experience with preparing lectures last year was that the :session option would cause Org Mode to capture all the output, i.e., the result of expressions in the block.

This year I started working on the same org file with an updated version of Emacs (26.1) and Org Mode (9.1.9). As you can see in my evaluation I only get the greeting messages and the output of print.

What happened to the values of the other expressions?

#+BEGIN_SRC elisp
(setq org-babel-python-command "/usr/local/bin/python")
(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (emacs-lisp . t)
   (python . t)
   ))
#+END_SRC

#+RESULTS:

#+BEGIN_SRC python :session :results output
import sys
print(sys.version)
4
print(3)
#+END_SRC

#+RESULTS:
: Python 2.7.15 (default, Jun 17 2018, 13:05:56)
: [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
: Type "help", "copyright", "credits" or "license" for more information.
: 2.7.15 (default, Jun 17 2018, 13:05:56)
: [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
: 3
: python.el: native completion setup loaded

I was expecting 4 to be in the output.

#+BEGIN_SRC python :session :results output
4-2
print(4+5)
#+END_SRC

#+RESULTS:
: 9

I was expecting 2 to be in the output.

Note: Setting :results to values would only print the last value of the function. My goal is to have exactly the same output as in the interactive interpreter: the values of all typed expressions and of all print statements.

Update: difference between Org 8 and 9

I did further testing. The following two files are actually the same org file but the result sections have been evaluated, respectively, with Org 8 and Org 9.

On Org 8 the following code prints all intermediate values:

#+BEGIN_SRC python :session :results output
4
print(5)
6
'bye bye'
print('bye bye')
#+END_SRC

#+RESULTS:
: 4
: 5
: 6
: 'bye bye'
: bye bye

On Org 9 it only prints the output of the program:

#+BEGIN_SRC python :session :results output
4
print(5)
6
'bye bye'
print('bye bye')
#+END_SRC

#+RESULTS:
: 5
: bye bye

Furthermore on Org 8 the evaluation does not stop at the error,
and  furthermore  Python  sees  the code  as  coming  from  <stdin>:

#+BEGIN_SRC python :session :results output
1
print(2)
3
4/0
5
print(6)
#+END_SRC

#+RESULTS:
: 1
: 2
: 3
: Traceback (most recent call last):
:   File "<stdin>", line 1, in <module>
: ZeroDivisionError: division by zero
: 5
: 6

In Org 9 the code stops at  the first error, and Python sees the
code as coming from a temporary file.

#+BEGIN_SRC python :session :results output
1
print(2)
3
4/0
5
print(6)
#+END_SRC

#+RESULTS:
: 2
: Traceback (most recent call last):
:   File "<stdin>", line 1, in <module>
:   File "/var/folders/kf/p7km5ptj1p52hvz5nl6j9gr80000gn/T/babel-Jbpwl4/python-oz33CG", line 4, in <module>
:     4/0
: ZeroDivisionError: division by zero

The behavior I was looking for was the one of my old version of Emacs which came with Org 8 instead of 9.

Apparently the mechanism of Python session evaluation has been changed from Org 8 to Org 9.


texts: Use completing-read to call arbitrary function

texts:
How can one pass a list of (arbitrary) functions to completing-read and run the selected candidate? Something like this:
(defun find/buffer ()
  (interactive)
   (completing-read "Chose one: "
            '(("find-file" . 'find-file)("switch-to-buffer" . 'switch-to-buffer))))


texts:
I'm learning emacs now and I've run into a problem.
I would like to use orgtbl minor-mode within an HTML file and be able to update the contents of the org table as HTML code directly.
I saw an YouTube video and got interested to do so. But I don't know how. Here is my code as entered in emacs.

I do not know where I'm wrong.


texts: How to customise Org-mode per file (and sync with Orgzly)

texts:
I am using Org-mode in conjunction with an Android tablet. I have customized Org-mode and keep files in Dropbox. After sync the Android side is not implementing any customization.

Copied this code to the head of the file:

(setq org-log-into drawer "LOGBOOK")
(setq org-use-fast-todo-selection '(prefix))
(SETQ ORG-todo-keywords
          '((sequence "TODO(t!)" "|" "DONE(d!)" "REPEAT(r!)")))
(setq org-todo-keyword-faces
          '(("TODO" . org-warning)
            ("DONE" . "yellow")
            ("REPEAT" . (:foreground "blue" :weight bold)))

But it does not get implemented in the Android side.

What am I missing?


texts:
I want to rename file in dired by replacing underscores with spaces. I hit
R Down (dired-do-rename) and after typing M-% (query-replace) I got:

query-replace-read-to: Command attempted to use minibuffer while in minibuffer

Is it possible to makes replaces in minibufer?

Is Recursive Edit here?

UPDATE I recall % r dired-do-rename-regexp but I ask about replacing in minibufer. Please do not count this workaround.


texts: How call the eval-sexp function with the right argument?

texts:
When I change something in a function, I need to move to the last parenthese of a function, and do C-x C-e.

I thought it would be nice if I can devise a keybinding to evaluate the function, while I'm in the middle of the function.

So I came up with the following:

(defun evaluate-sentence ()
  (interactive)
  (evil-set-marker ?8)
  (sp-end-of-sexp)
  (eval-last-sexp)
  (evil-goto-mark ?8))

The number 8 is just abritrary. You need to have Evil and Smartparens.
It sets the mark on the current position of the pointer, then go to the outer parenthese, eval it, and go back to the marked position.

I need to pass the correct arguments for eval-last-sexp. When looking up the documentation for C-x C-e, it says the following:

C-x C-e runs the command eval-last-sexp (found in global-map), which
is an interactive compiled Lisp function in
‘a:/Dropbox/Emacs/share/emacs/25.0.50/lisp/progmodes/elisp-mode.el’.

It is bound to <menu-bar> <emacs-lisp> <eval-sexp>, C-x C-e.

(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)

Evaluate sexp before point; print value in the echo area.
Interactively, with prefix argument, print output into current buffer.

Normally, this function truncates long output according to the value
of the variables ‘eval-expression-print-length’ and
‘eval-expression-print-level’.  With a prefix argument of zero,
however, there is no such truncation.  Such a prefix argument
also causes integers to be printed in several additional formats
(octal, hexadecimal, and character).

If ‘eval-expression-debug-on-error’ is non-nil, which is the default,
this command arranges for all errors to enter the debugger.

I'm not sure what the argument EVAL-LAST-SEXP-ARG-INTERNAL actually says. When I do an aprpos search with C-h a, he found nothing about what the argument EVAL-LAST-SEXP-ARG-INTERNAL really means. I would love to solve this myself, instead calling for help. But I'm out of ideas...

Any other suggestion?


texts: How to avoid accidentally writing temporary source-block-edit-buffers to file

texts:
When doing literate programming in org-mode, I frequently use C-c '[aka M-x org-edit-special] to enter the source-block-edit-buffer, so that I have appropriate yasnippets etc.

I then accidentally save this buffer with :w, and end up with files like
Network.org[*Org Src Network.org[ graphviz-dot ]*] littering my folder.

How can I avoid saving these files? Ideally, I would want the attempt to save the source-block-edit-buffer trigger saving the "parent" org file.

Edit: I now realize after the answer from @lawlist, that I was not having this problem every-time I save. Only, when I was using the :w evil ex mode command, not with C-x C-s. I use both, depending which is easier in context to type. I always thought this was equivalent, so I did not mention it when I first submitted the question. Sorry, since this sightly shifts the topic of the question.


texts: How to access the directory of the init.el file from elisp?

texts:
Is there a function/variable to access the directory the init file is in?

This could be: ~/.config/emacs/ or ~/.emacs.d/, for e.g.


texts: Org Mode: Prevent editing of text within collapsed subtree

texts: Is it possible to prevent editing of text within a collapsed subtree in Org Mode? That is, I would like to make it impossible to edit the hidden text. This seems like something that should exist but I haven't seen a way to do it.


texts: Decrease text indentation to level N after headline at level N+1

texts:
I am using org-mode to write papers and I am often confronted the following problem: starting from

* A
** A1
   Text for level A1
** A2
   Text for level A2

I want to add an additional information after Text for level A2 but at the level of A as follows:

* A
** A1
   Text for level A1
** A2
   Text for level A2
  Text stil in section A but not in section A2

But org mode does not seem to enable this and aligns the text with section A2.

I tried to insert an "artificial" section

*
  Text stil in section A but not in section A2

but it appears in the LaTeX export and therefore this is not a satisfactory solution. Is there a way to solve this problem, for instance by adjusting the export of the "artificial" section to make it invisible in the exported document ?


texts: Is there a way for magit to display the branch in the dired buffer mode line for a given directory?

texts: I'm moving to emacs from shell/Vim and I'm very used to seeing the branch I'm working in when I'm at the project level.  Is there any way to get the Git branch name to display in the dired buffer mode line for my projects?


texts: Org mode - Parsing rich HTML directly when pasting?

texts:
Currently, for notetaking tools like Evernote and Quiver, I can directly copy HTML content from my favorite browser and then paste them into the app, with all the formatting + link preserved. However in orgmode it seems that all the formatting info is lost.

I've seen somebody suggest using eww to browse the web and copy the content via eww-org. However that is really tedious(I don't think there would be a lot of people browsing the web using eww instead of modern browsers nowadays. I'll have to open that link again in eww and do the copying, not to mention sometimes eww doesn't render the contents nicely).

Is it possible to let Emacs directly parse the copied HTML when pasting? Even if there's no existing tool for that yet, is it feasible to make one?

This is almost the only thing that stops me from switching to orgmode from other notetaking tools.


texts: Highlight current line in GUD disassembler window

texts:
I am using GUD for debugging C code. Because many of the lines and variables have been optimized away, it is necessary to follow the C source and the corresponding disassembly simultaneously. I want the current line in the disassembler window to be highlighted each time I "step instruction." Right now the cursor moves automatically, in the disassembler window, but hl-line-mode does not highlight the line that the cursor moved to.  If I switch to that window, the new line gets highlighted, and remains highlighted when I move away from that window again.  But each time I step, the highlighting from hl-line-mode disappears in the inactive window.

How can I get a good visual indication of the "current line" in the disassembler window?  The tiny triangle in the fringe is not enough, because the lines are quite long, and it is difficult to tell at a glance which instruction will be executed next.


texts: org mode - babel params variable is void

texts:
After upgrade org mode version to 9, the babel variable params is void.

Below example works fine in org 8 version:

#+BEGIN_SRC emacs-lisp :results output
(print params)
#+END_SRC

#+RESULTS:
:
: ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace output") (:session . "none") (:hlines . "yes") (:colnames . "no") (:result-type . output) (:result-params "output" "replace") (:rowname-names) (:colname-names))

But if we run the same code in org 9.0.5, I got below error message:

let: Symbol’s value as variable is void: params

Is it changed to another name?


texts: With the new 25.1 installed, I'm wondering if there is a better way to view a Markdown inside an Emacs buffer. Would this involve xwidget? Not sure how to enable/install xwidget on my new Emacs 25.1.


texts: setq require-final-newline not working when setq-default does

texts:
I want all my files to end with only one newline, while trimming trailing whitespaces on regular lines.
Like so : ($ is newline face)
text$
$
last_line$

I use whitespace-cleanup in my init file, like so :
(add-hook 'before-save-hook 'whitespace-cleanup)

With whitespace-style :
(face tabs spaces trailing lines space-before-tab
 newline indentation empty space-after-tab
 space-mark tab-mark newline-mark)

To keep newlines I add :
(setq require-final-newline t)

Then eval-buffer my init file.
But Emacs does not take my setting unless I use setq-default. There is no mention in require-final-newline documentation that it is buffer local.


texts: Frequent anaconda-mode buffers pop-up with "No such file or directory"

texts:
Running spacemacs on OSX. Using Anaconda.

Every few keystrokes in a .py file, a buffer will pop up in anaconda-mode (which I have tried to disable with M-x anaconda-mode)

  /Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_9:
  path-to-project/venv/bin/python: No such file or directory

The minibuffer displays this message:

Cannot create ~/.emacs.d/.cache/anaconda-mode/0.1.7/ directory

This directory does exist.

I created the project on the command line with

conda create --name name-of-project-venv

The behavior basically makes spacemacs unusable for editing Python files.


texts: js2-mode on, still emacs hunts for javascript-mode

texts:
I enabled js2-mode in emacs by adding this snippet in .emacs,

(add-to-list 'auto-mode-alist '("\\.js$'" . js2-mode))

But still for .js files, emacs tries to load javascript-mode alias js-mode as
the major mode. And god knows, how did javascript-mode function go missing in my emacs. It crashes like this,

Debugger entered--Lisp error: (error "Autoloading failed to define function javascript-mode")
  javascript-mode()
  set-auto-mode-0(javascript-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer a.js> "~/a.js" nil nil "~/a.js" (1840059 2049))
  find-file-noselect("/home/sk/a.js" nil nil)
  ido-file-internal(raise-frame)
  ido-find-file()
  call-interactively(ido-find-file nil nil)

This leads to another question, does emacs consider the last (or) first regex entry in auto-mode-alist for loading the major mode?


texts:
I want to create a minor mode that translates selected text.
So I want to call a function when selection is changed.

How can I detect the change of selection?


texts: How to create a keybinding to a file in Emacs?

texts:
I have a frequently opened file in Emacs, which is deep inside my device. I want to bind the F5 key(or any other key) to open that file, how can I do that?
(Using android to run emacs. [GNURoot, Wheezy. ])


texts: How can I get org-mode clocktables to display (and sum up) appointments, like meetings for example?

texts:
Well, it is basically what the title says. I have the need to use clocktables to generate work reports, but I would like my meetings and other appointments to show up in the clocktables as well. I know that I could clock-in and then clock-out of the appointment to force them to show up in the clocktables, but I was wondering if there was some other (simpler) method.

Thanks in advance.


texts: Too much time spent for emacs to open cpp in the project

texts:
I use ggtags in order to improve my efficiency. I follow the manual to setup emacs environment.
https://tuhdo.github.io/c-ide.html

However, during editing the cpp files in the projects. Chance are high that the emacs will not respond. And the background will do something like "Parsing numeric_op.hpp (LL)...done". This will spend more than half an hour to do this. I don't know how to deal with this thing. Does anyone have the same situation?
Thank you very much.


texts: Getting latest command from function, but function exceeds "max-lisp-eval-depth"

texts:
This defines the Helm-source for Emacs commands history.

(defvar helm-source-emacs-commands-history
    (helm-build-sync-source "Emacs commands history"
    :candidates (lambda ()
                    (let ((cmds))
                    (dolist (elem extended-command-history)
                        (push (intern elem) cmds))
                    cmds))
    :coerce #'intern-soft
    :action #'command-execute)
    "Emacs commands history")

From this source you get the latest commands that you called with M-x. I would have a function, that calls the latest command that I called with M-x earlier. I read the documentation about list elements.

Function: car cons-cell
This function returns the value referred to by the first slot of the cons cell cons-cell. In other words, it returns the CAR of cons-cell.

As a special case, if cons-cell is nil, this function returns nil. Therefore, any list is a valid argument. An error is signaled if the argument is not a cons cell or nil.

(car '(a b c))
    ⇒ a
(car '())
    ⇒ nil

So I assume I need to replace the push with car, and return the result.

(dolist (elem extended-command-history)
(car (intern elem)))

But I got the error message

Debugger entered -- Lisp error (wrong-type-argument listp Info-next)
(Info-Next)

The Info-Next was indeed the latest command that I called with M-x.  However, I don't understand the error. Another way to get the latest called function.

(defun foobar ()
    (interactive)
    (call-interactively (intern (car extended-command-history))))

After calling foobar, I get the following error:

funcall-interactively: Lisp nesting exceeds `max-lisp-eval-depth'

Any suggestion to get the latest command?


texts: buffer-substring fails in linux in a non-X terminal when I am in anything other than text mode

texts:
NOTE: I was careless in evaluating this problem, and the data I posted here is not correct and does not reflect the actual issue that I am facing.

Since there are already answers to this question, I cannot delete it.

Please see the following question for the updated and corrected version of my query:

query-replace{-regexp} fails in linux in a non-X terminal when I am in anything other than text mode

Please ignore the rest of this. Thank you.

I am running emacs 26.1 under linux. It has been working fine for over a year. Recently, I upgraded a lot of packages on my machine, but I did not upgrade nor alter emacs in any way. Now, buffer-substring is failing when I run it in a non-X terminal with the -nw emacs command-line flag when not in text-mode. This failure never used to occur before my system upgrades. And it turns out that buffer-substring still works fine in all cases when I start emacs in an X window.

For example, suppose I have the following data in a file called test.txt ...

AAAA
BBBB
CCCC
DDDD

If I run emacs -nw test.txt, then (buffer-substring 0 1) works. However, if I run (elisp-mode) and then do a (buffer-substring 0 1), I get this error: args-out-of-range #<buffer test.txt> 0 1

This occurs no matter what arguments I pass to buffer-substring.  However, if I leave off -nw and do all the same things in an X-Window instance of emacs, buffer-substring always works.

In other words, with emacs test.txt (i.e., no -nw flag), I never get this problem with buffer-substring, no matter what mode I am running in.

This is not only specific to elisp-mode. The error with buffer-substring in a non-X terminal buffer also occurs for sh-mode and some other modes.

Does anyone know what could be causing this error and what I have to do to fix it?

Thank you in advance.

UPDATE:

I set debug-on-error and re-ran (buffer substring 0 1) in one of the cases that fails. Here is what I got:

Debugger entered--Lisp error: (args-out-of-range #<buffer test.txt> 0 1)
  buffer-substring(0 1)
  eval((buffer-substring 0 1) nil)
  eval-expression((buffer-substring 0 1) nil nil 127)
  funcall-interactively(eval-expression (buffer-substring 0 1) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

FURTHER UPDATE:

This error does not occur when I am running from my system console (with no X services running at all). The errors I saw did occur in xterm and urxvt windows under my X desktop manager, even when I have explicitly unset DISPLAY.

It seems like there is something about running within an X desktop manager which is confusing emacs with regard to buffer attributes when running with -nw, even with DISPLAY unset.


texts: I often find I want to close the nearest parent subtree, but don't know of a better way of doing this than navigating to the header first and then pressing tab.  I use evil-mode, so properly this should be the effect of zc, but it is not.


texts:
I got this warning when installing AUCTeX from GNU ELPA. The package is installed, but I don't want to use obsolete packages for obvious reasons. I have check the official website of AUCTeX, and it says current version is 12.1 (2017-12-10).

If this package is obsolete, which one is its replacement?


texts: Check the modified time of #+RESULTS file before exporting, then evaluate the code blocks selectively to save time?

texts:
Is there any configuration or package, which can make Org-mode checks the modified time of all #+RESULTS' files before export (maybe auto add a #+MODTIME for comparing I guess), then decide if a code block needed to be re-evaluate?

An Org file with a lot of gnuplot code blocks makes exporting very, very time-consuming...


texts: "Marker does not point anywhere" error when using (message)

texts:
I'm running into the error "Marker does not point anywhere" when I try to print a message both in after-change-functions and buffer-list-update-hook. Curiously if only one hook or the other is active the error does not occur, you have to have both! Precise code and steps to reproduce are below. Any advice on how to fix while keeping the message?

Tested on emacs 24.4.1 with -Q flag, on Ubuntu.

;; To reproduce:
;; 1. emacs -Q
;; 2. Have your frame display the scratch buffer, eval the code below in it
;; 3. Create a second frame (C-x,5,2)
;; 4. Have the second frame display the *Messages* buffer.
;; 5. Rapidly switch focus between the two frames
;; You should get the error: (error "Marker does not point anywhere")
;; Why? How do I prevent?

(setq-default debug-on-error t) ;; so you notice the error

(defun common-test (&optional a b c)
  (message "test"))

(add-hook 'after-change-functions #'common-test)
(add-hook 'buffer-list-update-hook #'common-test)

Also here is an example backtrace:

Debugger entered--Lisp error: (error "Marker does not point anywhere")
  message("test")
  common-test()
  run-hooks(buffer-list-update-hook)
  handle-switch-frame((switch-frame #<frame *Backtrace* 0x1218168>))
  call-interactively(handle-switch-frame nil nil)
  command-execute(handle-switch-frame)


texts: Use the terminal background color for the emacs -nw

texts:
I am looking for a way to force "emacs -nw" to use the same background color that the terminal uses. (just like vim does).
By default, every emacs theme has its own default background color. Whiteboard mode has white that is not the same white as my terminal.


texts: Running emacs client: how do you know if the init files had errors loading

texts:
I use emacs 25, in nw mode, with "alias emacs='emacsclient -nw'"
When I add something to my personal.el, I do

brew services restart emacs

My issue is, if I make a big blunder inside my personal.el file,
brew restart emacs daemon and start emacs client, there's no indication
that something has gone very wrong.

How do other folks do this?


texts:
If I create a string from the output of a shell command, using shell-command-to-string, I sometimes see ^H characters in the string, when I guess those characters were supposed to result in backspacing.

For example, I can produce such a result on my Debian-stable machine by doing

(shell-command-to-string "fortune -m MacKay")

for that particular fortune, the result contains the following substring The subspace _^HW inherits (where I've replaced a "non-printing character" by the string "^H", because that is what I "see" in Emacs).

If I just do fortune -m MacKay in a terminal (e.g. in eshell) the result contains instead the substring The subspace W inherits.

If I do something like

(insert (shell-command-to-string "fortune -m MacKay"))

in the *scratch* buffer, and then do "M-x describe-string" with point on the non-printing character (which - as I said earlier - appears in emacs as ^H) it is (unsuprisingly) described as

             position: 1442 of 2745 (52%), column: 15
            character: C-h (displayed as C-h) (codepoint 8, #o10, #x8)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x08
               script: latin
               syntax: _    which means: symbol
             to input: type "C-x 8 RET 8" or "C-x 8 RET BACKSPACE"
          buffer code: #x08
            file code: #x08 (encoded by coding system prefer-utf-8-unix)
              display: no font available
       hardcoded face: escape-glyph

What should I do to make shell-command-to-string "treat these deletion characters correctly?"

I doubt this has much to do with the Emacs version, but anyhow I'm using Emacs 25.1.50.18


texts: Dragging mouse in emacs results in strange output

texts:
If I click and drag my mouse within a buffer, garbage text appears all around the mouse.

I have tried (global-set-key [drag-mouse-1] 'mouse-set-region) with no effect.  I have otherwise no explicit remapping of mouse-1.  How can I redefine normal drag-mouse-1 behaviour or at least disable the current action?


texts: Quicklook in dired-mode using a process/sentinel with external viewer

texts:
In dired-mode, I use an external quicklook tool on OSX called qlmanage, which pops open a window displaying a human readable image of the file with mouse scrolling capabilities.  If I hit the space bar, qlmanage either displays the file or the process is deleted -- e.g., essentially an on/off switch.

I am having trouble figuring out how to move up or down in a dired-mode buffer, such that qlmanage will automatically display an image of the current line -- if an image is already being displayed -- but only do so after the previous process has successfully been killed with delete-process.  A successful kill of the qlmanage process will return a process-exit-status of 9 or the event string will equal killed\n.  I believe it is necessary to spawn a new process and sentinel when (= 9 (process-exit-status p); however, I am still confused by the nesting despite having had a few cups of coffee.  I would like to have one function dired-qlmanage that serves both purposes -- i.e., on/off with the space bar, or show next image if one is already displayed when moving up or down.

CAVEAT:  The goal is to avoid having more than one active qlmanage process at any given moment in time, which is why I am using a sentinel.

FYI:  "Deleting a running process sends a signal to terminate it (and its child processes, if any), and calls the process sentinel."  [Emphasis added.]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Deleting-Processes.html

  (require 'dired)
(require 'cl)

(defun dired-kill-last-process-named (name)
"Function initially written by @wvxvw, and revised by @lawlist."
  (let (p)
    (cl-loop with name-re =
             (format "^%s\\(?:<\\([[:digit:]]+\\)>\\)?" (regexp-quote name))
     for process in (process-list)
     for pname = (process-name process)
     if (string-match name-re pname)
     collect (cons (string-to-number (or (match-string 1 pname) "0")) process)
     into processes
     finally
      (let ((process (cdar (cl-sort processes '> :key 'car))))
        (when (and process (get-process process))
          (delete-process process)
          (setq p process)))) p))

(defun dired-qlmanage ()
(interactive)
  (unless (dired-kill-last-process-named "qlmanage")
    (let ((current-node (dired-get-file-for-visit)))
        (set-process-sentinel
          (start-process "qlmanage" nil "/usr/bin/qlmanage" "-p" current-node)
          (lambda (p e)
            (setq e (replace-regexp-in-string "\n$" "" e))
            (cond
              ((= 9 (process-exit-status p))
                ;; Should we spawn a new process with sentinel here?
                (message "killed (9):  %s | %s | %s" p e (process-exit-status p)))
              ((= 0 (process-exit-status p))
                (message "finished (0):  %s | %s | %s" p e (process-exit-status p)))
              (t
                (message "unknown (?):  %s | %s | %s" p e (process-exit-status p)))))))))

(defun my-dired-previous-line (arg)
(interactive "^p")
  (dired-previous-line arg)
  (dired-qlmanage))

(defun my-dired-next-line (arg)
(interactive "^p")
  (dired-next-line arg)
  (dired-qlmanage))

(defun my-dired-quicklook ()
(interactive)
  (dired-qlmanage))

(eval-after-load "dired" '(progn
  (define-key dired-mode-map [down] 'my-dired-next-line)
  (define-key dired-mode-map [up] 'my-dired-previous-line)
  (define-key dired-mode-map (kbd "SPC") 'my-dired-quicklook)))


texts: View buffers managed by other emacs instance

texts: Is it possible to run gnus or other things that tend to frequently block in a separate emacs instance and "forward the buffers" to the main emacs instance. I guess more generally I am wondering what kind of communication between emacs instances is possible.


texts: Matching org tasks against an interval of values

texts:
In a list of files I have org tasks with the property E such that each E is marked with an interval range.

* Some task1
:PROPERTIES:
:E: [E1, E3]
:END:

* Some task2
:PROPERTIES:
:E: [E4, E7]
:END:

...and so forth.

Question: How can I search through files and obtain an agenda view of all tasks that intersect within a range min to max?

So for example (search files 3 7) should display tasks that have, i,e., [E2, E4], [E4, E5] or [E6, E8] but not display tasks have [E1, E2] or [E8, E9].


texts: kill rectangle not working on Mac (missing file/library)

texts:
I just upgraded to emacs 26.2 using homebrew on my MAC (update: I had actually done a global "brew update" and assumed it had also updated emacs) and now kill-rectangle with
C-x r k no longer works, and instead gives me an error:

Cannot open load file: No such file or directory, rect

Any idea how I can get it back as it is a super useful feature...


texts: Magit appends '^M' (return) characters to git results

texts:
In the magit-status window Magit shows '^M" for many things. This is on FreeBSD, which should be using newlines instead:

This is, I think, the reason the push doesn't work right. From the magit-process buffer:

git … push -v origin master^M:refs/heads/master


texts:
Windows 10, Emacs 25.1, Magit.

If I want to select some regin in scratch buffer I use Shift arrow (or by mouse). It's work fine.
Here example:

Now I want to select text in Magit:

android:layout_width="0dp"

And do this by Shift arrow or by mouse.

Here result:

Why region is not select? It's very uncomfortable.


texts: How to be notified when a buffer/window becomes selected - no hook available?

texts:
I'm trying to run a piece of code when a buffer/window becomes selected. For an example use case, suppose I'm editing a buffer, save it, and kill it.

Suppose also the buffer "below" (that appears and becomes selected after my kill operation) has a list of files or something (like dired) that should be refreshed after I did my editing.

I was hoping to find a hook like buffer-selected-hook or window-selected-hook, preferably a local buffer hook, so that each time my "dired-like buffer" gets activated, it could run a refresh function.

I looked at many dozens of hooks with apropos, but couldn't see anything close to what I seek. Is there a standard way (or possible way) to run a piece of my refresh code when a buffer/window becomes selected?


texts: lsp-mode: How to use built-in clangd client?

texts:
I'm trying to use lsp-mode (together with company-lsp) for auto completion in C++. According to the docs[0], recent lsp-mode includes clangd support, so I should be all set when I do (require 'lsp-clients). However, lsp-mode can't find any clients to handle c++-mode, and from the documentation I can't find any way of debugging this.

The Main Problem

Here is the (almost) complete init.el file, which I have produced as a minimal example:

(unless (package-installed-p 'lsp-mode)
  (package-install 'lsp-mode))
(unless (package-installed-p 'company-lsp)
  (package-install 'company-lsp))
(unless (package-installed-p 'lsp-ui)
  (package-install 'lsp-ui))

(require 'company-lsp)
(require 'lsp-mode)
(require 'lsp-ui)
(require 'lsp-clients)

(push 'company-lsp company-backends)
(add-hook 'after-init-hook 'global-company-mode)

(add-hook 'lsp-mode-hook 'lsp-ui-mode)

(when (string= (system-name) "i11pcbarth")
    (setq lsp-clients-clangd-executable "/usr/lib/llvm-7/bin/clangd"))

(add-hook 'c++-mode-hook 'lsp)

Now, when I open a C++ file, I get the message

  Unable to find client(s) handling c++-mode. Make sure you have
  required lsp-clients.el or proper extension.

Since I already do (require 'lsp-clients) above, I'm not sure what to do.

Further Weirdness

Looking into lsp-clients.el, I can see that it should define e.g. the variable lsp-clients-clangd-executable. However, the variable seems not to be defined (I can't find it using C-h v). So, I assume that for some reason, the (require 'lsp-clients) from my init.el did not work. Thus, I require the file again (by typing (require 'lsp-clients) into the current buffer and calling eval-last-sexp). Now, C-h v sees the variable lsp-clients-clangd-executable. However, M-x lsp RET (to enable lsp-mode) again only gives me the error message about no client that handles c++-mode.

[0] https://github.com/emacs-lsp/lsp-clangd/blob/master/README.md


texts:
Preface this by saying I program but I'm not a programmer, and I especially don't know lisp.

I use org capture during code reviews, and we use line numbers as a way or organizing changes that need to be made. Is there a way to have org-capture include the line number that point was at when org capture was called?


texts: Sunrise-commander fails to launch, cannot split window

texts: Sunrise commander used to work fine. At some stage, and I am unaware when it happened, Sunrise now fails to launch. The error message I get is Window #<window 3 on init.el> too small for splitting.  I have also tried setting up these: (split-height-threshold 5) (split-width-threshold 5), unfortunately this does not work either. Any ideas?


texts: enabling additional flycheck-checker for spacemacs html layer

texts:
I can't seem to enable the scss-stylelint checker for scss-mode.

flycheck-verify-setup gives me this:

Syntax checkers for buffer _typography.scss in scss-mode:

  scss-lint (disabled)
    - may enable:         Automatically disabled!
    - executable:         Not found
    - configuration file: Found at "/Users/edbury/.scss-lint.yml"

  scss-stylelint
    - may enable:         yes
    - executable:         Found at /Users/edbury/.nvm/versions/node/v8.11.1/bin/stylelint
    - configuration file: Found at "/Users/edbury/some/path/.stylelintrc.json"

  sass/scss-sass-lint
    - may enable:         Automatically disabled!
    - executable:         Not found
    - configuration file: Not found

  scss
    - may enable: Automatically disabled!
    - executable: Not found

Flycheck Mode is enabled. Use SPC u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 32snapshot (package: 20190213.1525)
Emacs version:    26.1
System:           x86_64-apple-darwin17.5.0
Window system:    ns

So everything is configured correctly and it's ready to enable. Great! However, when I use SPC u C-c ! x to enable checkers, the only one that shows up in the list is scss-lint.

Since your input must match a list item, I can't enable scss-stylelint via this method.

I thought that my list of flycheck-checkers might be incomplete or something, but describing the variable gives me a complete list that includes the stylelint checker:

flycheck-checkers is a variable defined in ‘flycheck.el’.
Its value is
(d-ldc ada-gnat asciidoctor asciidoc c/c++-clang c/c++-gcc c/c++-cppcheck cfengine chef-foodcritic coffee coffee-coffeelint coq css-csslint css-stylelint cwl d-dmd dockerfile-hadolint emacs-lisp emacs-lisp-checkdoc erlang-rebar3 erlang eruby-erubis fortran-gfortran go-gofmt go-golint go-vet go-build go-test go-errcheck go-unconvert go-megacheck groovy haml handlebars haskell-stack-ghc haskell-ghc haskell-hlint html-tidy javascript-eslint javascript-jshint javascript-standard json-jsonlint json-python-json jsonnet less less-stylelint llvm-llc lua-luacheck lua markdown-markdownlint-cli markdown-mdl nix nix-linter opam perl perl-perlcritic php php-phpmd php-phpcs processing proselint protobuf-protoc pug puppet-parser puppet-lint python-flake8 python-pylint python-pycompile python-mypy r-lintr racket rpm-rpmlint rst-sphinx rst ruby-rubocop ruby-reek ruby-rubylint ruby ruby-jruby rust-cargo rust rust-clippy scala scala-scalastyle scheme-chicken scss-lint scss-stylelint sass/scss-sass-lint sass scss sh-bash sh-posix-dash sh-posix-bash sh-zsh sh-shellcheck slim slim-lint sql-sqlint systemd-analyze tcl-nagelfar tex-chktex tex-lacheck texinfo textlint typescript-tslint verilog-verilator vhdl-ghdl xml-xmlstarlet xml-xmllint yaml-jsyaml yaml-ruby)

Hopefully, I am missing something incredibly simple. Any insight?

Update Using flycheck-select-checker will allow me to manually select scss-stylelint. However, no linting occurs. I do get an error node: No such file or directory [env], which seems odd because flycheck-verify-setup returns the all clear.

Double Update This only happens in the GUI application. Running emacs in -nw resolves the issue; however, in GUI, running M-: (executable-find "node") does return the correct path (which matches flycheck-verify-setup).

Triple Update Even using flycheck-set-checker-executable, the binary can be located and set successfully, but the GUI app still returns the "not found" error.

Context I am using nvm, but the path correctly shows in exec-path. Clearly, flycheck is able to locate the executable, so something else is going on.


texts:
I use C-c a m to search for a tag, but the search is case-sensitive. By example if I enter gnuplot, only section B will be found
* section A     :Gnuplot:

* section B     :gnuplot:

Question: is it possible to do a case-insensitive tag search?

I know that:

I can do a tag search C-c a m with "gnuplot|Gnuplot"
I can do a "Search for keywords" using C-c a s which is case-insensitive, but this is a full text search (not only restricted to tags)

I would like to know if it is possible to do a "true" case-insensitive tag search (to catch "GnuPloT" too by example)


texts: Using org-mode for writing. Would like text in quotes to be highlighted and also character names

texts:
I'm using org-mode to write a novel and I would like to have any text between "quotes" to be a different color, just to be able to easily see when a character is talking.

Also, if I could have a list of names (in document) that are character names, and have those names highlighted too that would be awesome. Bonus if I can click them to go to a (in document) description of them.


texts: outshine mode changes outline-regexp from markdown's

texts:
patient StackExchange,

I am learning org-mode and liking its header-folding capacities, which seem much easier than outline-minor-mode. Most of my work is done in markdown mode, though, so I am trying (and failing) to set up outshine (from MELPA) in order to get org-like folding and restructuring.

Here is the weird (to me) behavior: with no change to my .emacs (other than MELPA's adding to package-selected-packages), it seems that when I load a markdown file, I can get the tab-folding behavior. This is weird since C-h m does not show outshine mode (but it does show outline-minor-mode, which my .emacs loads with hooks to text-mode etc). But I don't get any restructuring commands - when I hit alt-down, for example, I get <M-down> is undefined.

But if I manually load outshine in the markdown buffer, or load it with hooks in .emacs, then none of the folding works - and it seems that's because outline-regexp has suddenly changed to an asterisk-based one rather than a #-based one.

So my main questions:

How do I get outshine to leave markdown's outline-regexp alone?
Should I replace outline-minor-mode hooks in my .emacs with hooks to outshine, or add outshine hooks in addition to the outline-minor-mode ones?
Outshine is supposed to also be able to do restructuring with like  and such, right?

Thanks in advance, as always, for your time & attention.


texts: Embed Image as Base64 on HTML export from Orgmode

texts:
The goal is to make a self-contained html file when exporting from orgmode so that the images are intrinsic to the file and a single html file will can be distributed (I am trying to do this for a class I teach and want to give students a single html they can open in a browser).

I found a snippet of code on line that gives the idea of what I want:

#+BEGIN_SRC python :results output html :exports results
with open('/home/britt/Pictures/Britt0001.jpg', 'rb') as image:
    data = image.read()
    print '' % data.encode("base64")
#+END_SRC

And I am trying to get it into elisp and thus remove the dependancy on python and as a step to creating my own elisp function that could have some more detail.

Here is what I have gotten to. Advice appreciated.

#+BEGIN_src elisp :results output html :exports results
    (setq myim (concat ""))
     (print myim)
#+END_SRC

and where tob64 is

(defun tob64 (filename)
  (base64-encode-string
   (with-temp-buffer
     (insert-file-contents filename)
     (buffer-string))))

This doesn't give the correct formatting and quoting.

The goal to be worked toward is some variant of org-html-export-to-html where the elisp function could live and be invoked when an option like  #+OPTIONS: embed-images-on-html-export:t was invoked.

And as an aside, why doesn't the functionality of exporting to html with embedded images already exist in org-mode? Is there some bigger issue that makes this problematic for me to be working towards?


texts: Remember permission to execute "risky" local variables

texts:
In many of my projects I use .dir-locals.el files to setup project specific variables such as compile commands. Upon opening a file within a directory containing such a file, emacs complains about "risky local variables", specifically:

The local variables list in $DIR$/ contains variables that are risky (**)

Do you want to apply it? You can type
y  -- to apply the local variables list.
n  -- to ignore the local variables list.

** LaTeX-command : "lualatex -shell-escape"

I don't want to turn this feature off but I would like to be asked only once (during an emacs session) for a specific .dir-locals.el file.

I am using some plugins which want to parse the whole sourcetree and it is quite annoying to hit y hundreds of times just to parse everything.

So, the actual question:

  Can emacs' local-variable loading mechanism be configure / modified such that it allows to allow / deny loading of a specific local variables list for the entirety of an emacs session?


texts: How to make org-habit shift between days at 04:00 instead of midnight?

texts:
org-habit keeps track of my habits, e.g. taking a piece of melatonin pill every day before bed. Sometimes I go to sleep after midnight. I don't want the habit to count as failed in this case. I want orgmode and org-habit let me check the habit before or after midnight. How do I do that?

Right now I have it scheduled like this: SCHEDULED: <2017-10-04 Wed .+1d>

The other problem is that if I check it at 2 am, then it list it in the agenda on that day even if I want to go to sleep before midnight.


texts:
I'm getting this error while trying download a package from ELPA:

 Failed to verify signature archive-contents.sig:
 No public key for 474F05837FBDEF9B created at 2018-11-28T14:10:03-0800 using DSA
 Command output:
 gpg: keyblock resource '/c/apps/emacs-25.3_1/bin/c:/users/myuserid/.emacs.d/elpa/gnupg/pubring.kbx': No such file or directory
 gpg: Signature made Wed Nov 28 14:10:03 2018 PST
 gpg:                using DSA key CA442C00F91774F17F59D9B0474F05837FBDEF9B
 gpg: Can't check signature: No public key

I've been doing some clean up in my init file but I don't see how it could have impacted this.  In a way it's a good thing because it's a good opportunity to setup gpg but it's not working for me.  I used customize-apropos to set these values:

  '(epg-gpg-home-directory "C:/Program Files/Git")
  '(epg-gpg-program "gpg.exe --homedir /c/users/myuserid/.emacs.d/elpa/gnupg")

I'm using the gpg that comes with my git client.  However, no matter what I set it doesn't seem to care, it still has the invalid path the keys.

What could be causing these gpg variables to not be respected??